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

minhthong095 commented Jan 6, 2020

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

This comment has been minimized.

Copy link

ZhengYuTay commented Jan 6, 2020

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

Copy link
Owner

comigor left a comment

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 minhthong095 requested a review from comigor Jan 7, 2020
@minhthong095

This comment has been minimized.

Copy link
Contributor Author

minhthong095 commented Jan 9, 2020

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 and others added 3 commits Jan 10, 2020
Co-Authored-By: Igor Borges <igor@borges.dev>
@minhthong095

This comment has been minimized.

Copy link
Contributor Author

minhthong095 commented Jan 11, 2020

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

comigor added 2 commits Jan 13, 2020
Given GitHub token assignment for forks
@comigor comigor merged commit 65b29d4 into comigor:master Jan 13, 2020
2 of 3 checks passed
2 of 3 checks passed
package-analysis package-analysis
Details
test
Details
check-version-and-changelog
Details
@comigor

This comment has been minimized.

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
Projects
None yet
3 participants
You can’t perform that action at this time.