-
Notifications
You must be signed in to change notification settings - Fork 470
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
"No operations or fragments" error during client:codegen #719
Comments
Since Apollo 2, I have been getting the same error using
The files do exist, have proper syntax, and a legitimate schema.json because I can generate types using apollo v1. My machine specs: The error:
|
I have the same problem.. It can't handle relative paths in the includes field. apollo client:codegen src/types -c=apollo.config.js --target=typescript --outputFlat apollo.config.js. |
@chenglabs Interesting that you managed to get it to work at least. I just tried it with absolute paths, and I was not able to get it to work. Could you please provide us with the specifications of your system you are working on? |
I used the full pathname for the --queries arg instead of the relative path used above. Still no luck. Same result and completely blocked. |
I just saw in another issue thread this command was working in [email protected]. I downgraded and yay it worked fine. |
Hi, check example at https://github.com/chenglabs/test_apollo_client |
@chenglabs I was able to reproduce the issue you were seeing. If you remove the leading
|
@ZenSoftware @chrishandorf do either of you have a reproduction on codesandbox/glitch/github that I could look at? |
@JakeDawkins |
Hey. Got the same issue on macOS so I don't think it's Windows related 🤔 Unfortunately I don't have a lot of insights to offer... |
Ok, did some debugging in the Apollo code It's missing one slash.. (https://en.wikipedia.org/wiki/File_URI_scheme) |
@chenglabs If I make the above change you suggested locally I get this: $ apollo client:codegen --queries='src/app/graphqlPublic/*.graphql' --localSchemaFile=schema.json --target=typescript @JakeDawkins I could work on a minimal set of files to reproduce the problem if that would be helpful. I haven't used codesandbox. Is there another way I could send you the fileset? |
This seems like the root of the issue:
I'm going to try to get a Windows environment set up since I need to be able to reproduce issues like this that pop up. @chenglabs @chrishandorf I see the same issue with the 3 slashes. It looks like VSCode's URI implementation takes care of the third slash: let uri = Uri.file('/users/me/c#-projects/');
assert.ok(uri.scheme === 'file');
assert.ok(uri.authority === '');
assert.ok(uri.path === '/users/me/c#-projects/');
assert.ok(uri.query === '');
assert.ok(uri.fragment === '');
assert.ok(uri.toString() === 'file:///users/me/c%23-projects/') https://github.com/Microsoft/vscode-uri @chrishandorf a repo that we can clone is best! |
@JakeDawkins @trevor-scheer please see this: https://github.com/chrishandorf/apolloError Its completely bare bones and not working |
@chrishandorf super helpful, thank you! I've got a PR open now for better CLI flag support here: Your configless example helped me find an edge case that I'll be submitting a fix for soon. Looks like behavior is a little wonky when no config is provided. |
@chrishandorf PR for configless bug: #734 |
@trevor-scheer many thanks and I think its getting better, but it seems to be picking up some graphql files outside of the ones I specified in my --queries. I have 3 graphql folders containing *.graphql files. They are basically public/customer/admin graphql folders. When I try to process the public folder (graphqlPublic) it gets errors from the customer folder (graphqlCust): $ apollo client:codegen --queries='src/app/graphqlPublic/*.graphql' --localSchemaFile=publicSchema.json --target=typescript --outputFlat src/app/graphqlPublic/gen I currently have everything working by using [email protected] to download the schema.json file using the --endpoint option, then I revert to [email protected] to do the codegen. Clearly I would like to do it all with 2.1.2. Should I create another repo? |
@chrishandorf I just published If there are still issues, another reproduction is always appreciated! I'd like for this thread to not turn into an assimilation of multiple codegen related issues, so if you don't mind opening another issue that would be preferable. Thanks again 😄 |
I am still getting the error with 2.1.3... but I am not sure if it is coming from #723 not finding the tags or from my glob not reading the correct files...
here is the exact error
|
@deltaskelta apollo client:codegen src/types --target=typescript --outputFlat --endpoint=https://graphql-pokemon.now.sh --includes=D:/Projects/GraphQL/demo/pokemon/src/queries/** |
I am also still getting the error as of 2.1.3 unfortunately. Thanks for trying though @trevor-scheer. I have tried all sorts of things: Absolute paths, relative paths, different glob patterns, --queries flag, and using an apollo.config.js. Nothing has worked yet unfortunately. I am on Windows, though I am not entirely convinced it is a Windows specific issue. I see that there are 2 users in this thread on Mac getting this error. ^_^ |
I'm on Mac so it is definitely not a Windows only issue. I have tried different glob patterns, |
@ZenSoftware @deltaskelta |
release 2.1.3 is now working perfectly for me |
@chrishandorf glad to hear it! Thanks for working with me on this 🎉 @deltaskelta this sounds like it's a @ZenSoftware I think the Windows issue is the last one standing here. I've got access to a Windows environment now, so if you can help me out with a basic reproduction that would be helpful! |
I just tried with gql tags and I still have the issue |
I made a reproduction here https://github.com/deltaskelta/apollo-cli-719 |
@trevor-scheer I just cloned @deltaskelta reproduction. I can confirm that |
Much appreciated! Not sure how soon I'll get to it, I'm away for the next week. If I find some free time to take a look then I may, otherwise maybe @JakeDawkins can take a look after the weekend? |
I was able to get this to work by upgrading to [email protected]. I am on on MacOS. |
On MacOS and [email protected] my files with |
@trevor-scheer This issue is now resolved for me. I installed [email protected] and it is working just fine now! (I am one of the Windows users) (Sorry I jumped the gun, read the comment below) |
I'm sorry. I may have jumped the gun in claiming that I have gotten it to work. I managed to get it to work using a convoluted approach that happens to work for our current project. I got it to work by using a Gulp Task that executes the But if I just use |
I just tried my https://github.com/deltaskelta/apollo-cli-719 with 2.1.7 and it is still failing for me |
@deltaskelta I just cloned your repo and can confirm that all that's left for you is the @ZenSoftware can you share some more info for me?
Thanks everyone for all the feedback here, it's been super helpful 🎉 |
I'm trying
and getting
|
Hello, I use the latest version of project (2.1.7)
and as result I'm receiving (on Windows 10 and MacOS 10.14)
|
Hi @alexcibotari , try to use |
I @brabeji
and even json configuration
result is the same: error |
@alexcibotari where are your query files located? By default, |
I've found the cause of this. This code breaks on Windows: apollo-tooling/packages/apollo/src/Command.ts Lines 179 to 182 in 99bb221
The reason is that a proper absolute URI on Windows is import Uri from "vscode-uri";
const rootURI =
filepath === process.cwd()
? Uri.file(filepath)
: Uri.file(parse(filepath).dir); This fixes Apollo not being able to properly discover queries and fragments within a project. There is however another problem related to how relative URIs are generated later on. During code generation
However it's later used here:
That call to This can be fixed by initializing const { rootPath = Uri.file(process.cwd()).path } = options; This fixes files not being written. There is however yet another problem sitting even deeper: the relative import paths of the generated files use backslashes instead of forward slashes. |
@patrys this is a great find! We should setup appveyor for sure! |
@patrys you are an example of why the open source community gives me hope for humanity. Well done my friend ^_^ |
My issue seems to be fixed as of 2.1.8 |
My issues are resolved as well as of 2.1.8. (I am Windows user) |
Thanks for reporting back! I believe all that's left is the Windows issue, so I'm going to close this and point to the open PR #810. We're currently investigating CI for both Windows and Linux in order to catch env-related FS issues in our tests 🙂 |
Hi @trevor-scheer |
@chenglabs that's correct, those changes haven't been merged yet. You can keep an eye on the status of the PR to know when it lands in master. |
Hi, Fail to generate the schema types when I'm using @client directive while using a query component and generating query using gql tag. Getting the following error :: Here, abc and xyz are the local variables created using @client directive. |
Hey @SanchiSinghal, this sounds unrelated to the issue mentioned here. Would you mind opening a separate issue? Thanks! |
I'm running client:codegen on apollo/2.1.2 darwin-x64 node-v10.13.0
(iMac)
The endpoint is successfully reached but codegen can't seem to find any files that are specified using the --queries option. The files do exist though. I get the same error if I use --localSchemaFile=schema.json instead of --endpoint. See the 2 commands run below:
$ apollo client:codegen --target=typescript --endpoint=http://localhost:8080/graphql --queries="./src/app/graphqlPublic/*.graphql"
✔ Loading Apollo Project
✖ Generating query files with 'typescript' target
→ No operations or fragments found to generate code for.
Error: No operations or fragments found to generate code for.
at write (
/.npm-global/lib/node_modules/apollo/lib/commands/client/codegen.js:58:39)/.npm-global/lib/node_modules/apollo/lib/commands/client/codegen.js:83:46)at Task.task (
$ cat ./src/app/graphqlPublic/page-visit.graphql
query PageVisit($page: String!){
pageVisit(page:$page)
}
The text was updated successfully, but these errors were encountered: