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

Inconsistent behavior for directives #247

Closed
kantum opened this issue Jan 19, 2023 · 2 comments
Closed

Inconsistent behavior for directives #247

kantum opened this issue Jan 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kantum
Copy link

kantum commented Jan 19, 2023

Describe the bug
On a big schema from Hasura, directives are sometimes added, but disappear if genqlient is run again.

To Reproduce
See https://github.com/kantum/genqlient-bug

Expected behavior
Running genqlient twice should give the same result.
Directives should be applied.

genqlient version
v0.5.0

@kantum kantum added the bug Something isn't working label Jan 19, 2023
@kantum
Copy link
Author

kantum commented Jan 20, 2023

I solved it:

It was about this line in genqlient.yaml:

operations:
- operations/**/*.graphql

Apparently, I have to explicitly specify a name for files.

This works:

operations:
- operations/**/InsertUserOne.graphql

Maybe related to #167

@benjaminjkraft
Copy link
Collaborator

Thanks for the repro!

The real problem here is described in #123. Specifically, you have inconsistent directives on UserInsertInput in each operation -- all of the operations ultimately refer to UserInsertInput but only InsertUserOne has the directive. Unfortunately at the moment the behavior is we use whichever set of directives we see first, which when you combine it with globbing is potentially nondeterministic (it depends on the order that we get the files from the file system). Anyway, the fix is to put that directive on all your queries that might refer to UserInsertInput; fixing #123 would give you validation to tell you that explicitly.

(With that said, you're right that as described in #167 your ** isn't doing anything! But that doesn't matter since you just have one level of nested directories anyway, so the equivalent operations/*/*.graphql will do fine.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants