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

Error: Introspection result missing directive locations #665

Closed
noahemmet opened this issue Jul 24, 2019 · 6 comments
Closed

Error: Introspection result missing directive locations #665

noahemmet opened this issue Jul 24, 2019 · 6 comments

Comments

@noahemmet
Copy link
Contributor

Hi! I'm upgrading to version 0.13.0 and I'm running into some issues with the build script. When I run it, I get the following error:

++ npx --no-install apollo codegen:generate Views/GraphQL/ViewQueries.generated.swift --target=swift '--includes=./**/*.graphql' --localSchemaFile=Views/GraphQL/Schema.json --passthroughCustomScalars

Loading Apollo Project [started]

CLIError: Error in "Loading schema for Unnamed Project": Error: Introspection result missing directive locations: { onField: true, onOperation: false, args: [[Object]], name: "include", description: "Directs the executor to include this field or fragment only when the `if` argument is true.", onFragment: true }

    at Object.error (Project/Views/node_modules/@oclif/errors/lib/index.js:22:17)

    at Generate.error (Project/Views/node_modules/@oclif/command/lib/command.js:57:23)

    at OclifLoadingHandler.showError (Project/Views/node_modules/apollo/lib/OclifLoadingHandler.js:28:22)

    at OclifLoadingHandler.handle (Project/Views/node_modules/apollo/lib/OclifLoadingHandler.js:13:18) {

  oclif: { exit: 2 },

  code: undefined

}

Loading Apollo Project [failed]

My build script is set up like so:

cd "${SRCROOT}"
$APOLLO_FRAMEWORK_PATH/scripts/check-and-run-apollo-cli.sh codegen:generate "Views/GraphQL/ViewQueries.generated.swift" --target=swift --includes=./**/*.graphql --localSchemaFile="Views/GraphQL/Schema.json" --passthroughCustomScalars

A few notes:

  • I'm using Xcode 13 and Swift Package Manager, which was working with version 0.12.0.
  • I'm not using any @directives in my .graphql files.
  • The backend is running SwiftGraphQL, so it's possible it's generating a Schema.json file that's incompatible with the latest Apollo code gen?
  • I've tried various combinations of quotes/no-quotes, removing --passthroughCustomScalars, and some --includes path globs.

Any ideas? Thanks!

@noahemmet
Copy link
Contributor Author

Looks like the error message was added in graphql/graphql-js#1429, in response to dotansimha/graphql-code-generator#556 (comment).

So yeah, I think it's a backend issue. It's a bit late over here and I'm a bit blurry, so I'll tackle this in the morning, but any thoughts on how much backend work this might be? I can't tell how much the introspection schema's changed since last year, heh…

@designatednerd
Copy link
Contributor

Definitely seems like the error is in parsing the schema - if you try to parse it locally using the apollo CLI, is it parsing?

I honestly haven't the faintest idea how much work that is on the BE, I'm pretty purely a mobile dev. I know the team has tried to keep the changes as minimal as possible but I'd look at the migration guides from 1.x to 2.x for the CLI, that might have some suggestions

@designatednerd
Copy link
Contributor

@noahemmet Since it seems like this is an issue with some combo of backend and tooling rather than with iOS specifically, do you mind if we close this out?

@noahemmet
Copy link
Contributor Author

do you mind if we close this out?

Go for it!

@noahemmet
Copy link
Contributor Author

Figured it out! The Vapor extension I was using wasn't including the directives field in the introspection query: StevenLambion/GraphQLRouteCollection#3

@designatednerd
Copy link
Contributor

Ooh! Neat project 🤓

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

No branches or pull requests

2 participants