Implemented fragments shared between multiple queries by FabioStatespace · Pull Request #18 · statespacelabs/SimpleGraphQL-For-Unity · GitHub
Skip to content

Implemented fragments shared between multiple queries - #18

Open
FabioStatespace wants to merge 1 commit into
masterfrom
fabio/universal-fragments
Open

FabioStatespace wants to merge 1 commit into
masterfrom
fabio/universal-fragments

Conversation

@FabioStatespace

Copy link
Copy Markdown

This has no priority right now but it may be useful in the future to differentiate only some parts of some queries between platforms using Fragments

  • .graphqlfrag files are parsed as GraphQLFragmentFile that contain a Fragment definition
  • It's possible to add fragments in GraphQLConfig that are loaded in a Dictionary in GraphQLClient
  • Queries now contain a list of all Fragment names that they references, that list can be used to get Fragments from the graphql client
  • Query.ToRequest accept an IEnumerable to append Fragments to the query

To make it work in addition to this PR it requires to change the request creation in GraphQLUtility:QueryInternal like this:

var fragments = _client.FindFragments(query.Fragments);
var request = query.ToRequest(args, fragments);

.graphqlfrag files are parsed as GraphQLFragmentFile
It's possible to add fragments in GraphQLConfig
Queries now contains a list of all Fragments that they references, that list can be used to get Fragments from graphql client
@FabioStatespace FabioStatespace self-assigned this Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants