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

buildClientSchema, introspection result missing interfaces #1207

Closed
iambumblehead opened this issue Jan 9, 2020 · 14 comments
Closed

buildClientSchema, introspection result missing interfaces #1207

iambumblehead opened this issue Jan 9, 2020 · 14 comments

Comments

@iambumblehead
Copy link

I'm trying to use graphql's buildClientSchema to generate a schema that can be used for mocking/testing components as seen in this link.

This error is thrown and I'm un-sure how to proceed,

Error: Introspection result missing interfaces

To try and simplify the situation, I've modified the schema slightly for now to define one type.

jsonSchema.__schema.types = [ jsonSchema.__schema.types[0] ];
const schema = buildClientSchema( jsonSchema );

and the following is the error result,

Error: Introspection result missing interfaces:
{ kind: "OBJECT", name: "Query", possibleTypes: null }

The service originating the schema and the sources calling buildClientSchema are using graphql version 14.5.8.

I would be glad if someone would tell what I'm doing wrong and would welcome any solution.

@acao
Copy link
Member

acao commented Jan 9, 2020

it looks like you need to build a full schema, rather than a schema with a specific type. you'll need to define the base operation types first, thus the error

also maybe you are looking for https://github.com/graphql/graphql-js? this is the graphiql monorepo for the web IDE and official graphql lsp tooling

@iambumblehead
Copy link
Author

iambumblehead commented Jan 9, 2020

@acao thank you for looking at my issue. I removed the line which redefines types so that the entire schema is being used (schema is requested using this query btw)

query: '{ __schema { types { kind, name, possibleTypes { name } } } }'

The same error still occurs, even when the full schema is used.

I'll take a look at graphql-js. My end goal is to customize query and mutation behaviour for test components using addMockFunctionsToSchema, in a way that is similar to the somewhat dated blog post here.

@acao
Copy link
Member

acao commented Jan 9, 2020

indeed, the graphql slack is actually a great place for support on this issue, or the apollo spectrum. again this really isnt in our wheelhouse, so im helping as a peer because i dont maintain this code, though I help them review Prs sometimes. we also use the official graphql package (aka graphql-js) but we aren’t maintaining it in this repo.

@acao
Copy link
Member

acao commented Jan 9, 2020

its confusing i know, the repo names, but the buildClientSchema method lives in graphql-js repository

@iambumblehead
Copy link
Author

@acao I am in the slack general channel and have pasted a link there to this github issue

@acao
Copy link
Member

acao commented Jan 9, 2020

Ok, I’ve been sick and havent used a laptop today, but I might hop on later tonight and may be able to get around to helping you with this issue? usually the slack channel is quite helpful, as is the apollo spectrum channel.

@acao
Copy link
Member

acao commented Jan 9, 2020

but off the cuff, I think you'd only have this bug regarding name: “Query” if you dont define a root level Query field/object in your schema

@iambumblehead
Copy link
Author

@acao thank you I will try a few things out using your insight

@iambumblehead
Copy link
Author

iambumblehead commented Jan 10, 2020

@acao again thank you for your assistance. I tried using a utility file to make the introspection query and it seems to have resolved this issue,

const introspectionQuery = require( 'graphql/utilities/introspectionQuery' ).introspectionQuery;
// used in the query as  `query: introspectionQuery`

The schema which is returned has more definition that the previous schema

I'll close this ticket later today when I'm further along

@acao
Copy link
Member

acao commented Jan 10, 2020

yep that sound about right! that const will be deprecated in soon to be released 15 since its dynamic now, i’d suggest using:

const { getIntrospectionQuery } = require(‘graphql/utilities/introspectionQuery’)

// and then
query: getIntrospectionQuery()

@iambumblehead
Copy link
Author

@acao :) thank you

@iambumblehead
Copy link
Author

I haven't quite resolved this issue and am seeing errors related to scalar values needed in the responses.

{
  "message": "GraphQL error: No mock defined for type \"UUID\""
}

This graphql/graphql-js issue might be related? @acao if you are available do you have any ideas for things I might try as a solution?

@iambumblehead
Copy link
Author

iambumblehead commented Jan 13, 2020

This looks very related ardatan/graphql-tools#545

The service originating the schema relies on dozens of complex scalar values. It seems graphql-tools may not be suited for mocking services that use custom scalar values...

@iambumblehead
Copy link
Author

I found that all of the queries values must be returned and must not be undefined, otherwise the mock function must be defined... resolved

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