-
Notifications
You must be signed in to change notification settings - Fork 158
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
introduced a simple query extraction mechanism for single-file multi … #458
base: main
Are you sure you want to change the base?
introduced a simple query extraction mechanism for single-file multi … #458
Conversation
…query code generation with the cli
Would be nice to support mutation and subscription too? |
We would at least need tests to make sure nothing breaks. I also think the string matching isn't robust enough. We do parse the queries with I see one reason not to do this: validation errors from the server. They will return file positions in the query the server received. It's confusing for users if they get an error with a position in a document they did not write but that was constructed from their queries. |
@tomhoule
About validation errors, i understand the concern and this might be a problem if you have a lot of large queries in a single file. But to my experience if thats the case, you already need to manually modify the query_string variable in the generated code which would cause the same issue (the file position not matching the actual query file). Another idea would be splitting the large query file into multiple files with a single query in them, but this beats the purpose of containing related queries into the same query file (which what got me going in the first place) |
What I had in mind would have been using the |
@tomhoule
i have tried to not touch any of the |
This pr aims to address this issue : #433
If there are multiple queries in the same file, they are all concatenated into one string which requires manual adjustments after generation. This function extracts the relevant query string. It assumes that all queries start with "query operation_name" and are followed by another "query".
If the extraction fails due to some reason, the original query string is returned, so the original behavior is not modified. It also handles the case of just one query in a single file.