Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing fragments #65

Merged
merged 11 commits into from
Jan 13, 2020
Merged

Sharing fragments #65

merged 11 commits into from
Jan 13, 2020

Conversation

minhthong095
Copy link
Contributor

Sharing fragment between queries and schemas.

This feature only enable if developer declare input fragments_glob like those configuration. If it isn't declared, Artemis will turn back to original.

Will work well if it is declared within queries_glob defined on directly path.

Good

- schema: pokemon.schema.json
  queries_glob: graphql/a.graphql
  output: lib/graphql/a.dart
- schema: pokemon.schema.json
  queries_glob: graphql/b.graphql
  output: lib/graphql/b.dart

Failed

- schema: pokemon.schema.json
  queries_glob: graphql/*.graphql
  output: lib/graphql/common.dart

Because in original source, even if i have 2 fragments with same name, add_query_prefix: true in 2 different files, different query (operation) name and build.yaml config like 'Failed' above. Artemis will not generate too.

So i came up with that solution.

In a huge project my team working on it's convenient to use sharing fragments.

Already considered this issue: #52

@ZhengYuTay
Copy link

I think it's good if we can add a working fragment example.

Copy link
Owner

@comigor comigor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there @minhthong095! First of all, thanks for this PR.

Although I still think the proper approach to this enhancement would be to have middlewares, I was unable to fully work on it yet, so this PR would be the best solution for this for the time being.

However, we need to have tests (and examples) of how to use this new configuration, along with proper changes on documentation.

Could you do those changes? Ping me if you need any help!

@minhthong095
Copy link
Contributor Author

Hi @comigor , I implemented test, examples and correct little code in fragment_query.dart and fragment_query.query.graphql for suitable with this feature. Let me know if i need to do something else. Thanks

README.md Outdated Show resolved Hide resolved
test/query_generator/fragment_generator_test.dart Outdated Show resolved Hide resolved
@minhthong095
Copy link
Contributor Author

Hi @comigor, just updated Could you take a look?

@comigor comigor merged commit 65b29d4 into comigor:master Jan 13, 2020
@comigor
Copy link
Owner

comigor commented Jan 13, 2020

Released as 2.2.0

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.

None yet

3 participants