angel-dart / angel

[ARCHIVED] A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://angel-dart.dev/
MIT License
1.06k stars 67 forks source link

Exception in GraphiQL when using custom types? #241

Closed nlfiedler closed 3 years ago

nlfiedler commented 4 years ago

Using either angel_graphql 1.0 and defining a custom scalar (e.g. BigInt), or using angel_graphql 2.0 and using the Upload type, an exception is displayed in the results panel of the GraphiQL interface. Maybe something about the type definition is not what graphiql expected? Maybe I'm missing something?

getNamedType@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:31062:22
getType@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:31049:33
getOutputType@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:31076:23
https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:31197:28
https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:25140:36
reduce@[native code]
defineFieldMap@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:28275:30
getFields@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:28236:58
typeMapReducer@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:29953:34
https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:29963:34
forEach@[native code]
typeMapReducer@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:29954:34
reduce@[native code]
GraphQLSchema@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:29842:40
buildClientSchema@https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:31250:35
https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.11.11/graphiql.js:2186:55
promiseReactionJob@[native code]
thosakwe commented 4 years ago

Hm, to be honest, it's very difficult to tell, because there is not a lot of information. The error seems to be:

throw new Error('Invalid or incomplete schema, unknown type: ' + typeName + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.');

angel_graphql 2.0 is still in beta, so I wouldn't expect it to be bug-free for the time being. I'll leave this open, because there's more digging to do to find what the underlying cause is (and graphiql's error message is not very descriptive at all).

nlfiedler commented 4 years ago

It happens with angel_graphql 1.0 as well, when defining a custom type. With either 1.0 or 2.0, if you are not using a type outside of the graphql_schema package, then it's fine. But yeah, there's not much else to go on here, sorry.

thosakwe commented 4 years ago

Ah, wait. Here's a workaround - the GraphQL constructor takes an additionalTypes argument, which can be used to add types to the schema directly. The introspector should automatically pick up any types from your given schema, though, so I guess that's what will need to change.

On Sun, Mar 1, 2020 at 7:53 PM Nathan Fiedler notifications@github.com wrote:

It happens with angel_graphql 1.0 as well, when defining a custom type. With either 1.0 or 2.0, if you are not using a type outside of the graphql_schema package, then it's fine. But yeah, there's not much else to go on here, sorry.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/angel-dart/angel/issues/241?email_source=notifications&email_token=ACMIUPB2LPBO2VC2J3773KTRFL7R5A5CNFSM4K7BG5Q2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENNSAQI#issuecomment-593174593, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACMIUPEZV5UIKONLZE4M4QTRFL7R5ANCNFSM4K7BG5QQ .

--

Tobe Osakwe Student, B.S. Comp. Sci, Florida State University https://thosakwe.com

nlfiedler commented 4 years ago

Thanks for the suggestion. I found the customTypes and tried that:

final graphql = GraphQL(
  graphQLSchema(
    queryType: queryType,
    mutationType: mutationType,
  ),
  customTypes: [
    bigIntType,
    graphQLUpload,
  ],
);

But that change did not resolve the error. I'm guessing something else must be done with the custom types further down the line.