question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create Schema Definition from Introspection Result is ignoring Custom Scalar from Server

See original GitHub issue

Hi guys,

I am trying to use graphql-java to send graphql queries to prisma graphql server. However, it fails to create GraphQLSchema with the introspection results from prisma grpahql server due to the ‘DateTime’

Introspection

query IntrospectionQuery {
  __schema {
    queryType {
      name
    }
    mutationType {
      name
    }
    subscriptionType {
      name
    }
    types {
      ...FullType
    }
    directives {
      name
      description
      locations
      args {
        ...InputValue
      }
    }
  }
}

fragment FullType on __Type {
  kind
  name
  description
  fields(includeDeprecated: true) {
    name
    description
    args {
      ...InputValue
    }
    type {
      ...TypeRef
    }
    isDeprecated
    deprecationReason
  }
  inputFields {
    ...InputValue
  }
  interfaces {
    ...TypeRef
  }
  enumValues(includeDeprecated: true) {
    name
    description
    isDeprecated
    deprecationReason
  }
  possibleTypes {
    ...TypeRef
  }
}

fragment InputValue on __InputValue {
  name
  description
  type {
    ...TypeRef
  }
  defaultValue
}

fragment TypeRef on __Type {
  kind
  name
  ofType {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }
}

Introspection Result

{
  "data": {
    "__schema": {
      "queryType": {
        "name": "Query"
      },
      "mutationType": {
        "name": "Mutation"
      },
      "subscriptionType": {
        "name": "Subscription"
      },
      "types": [
        {
          "kind": "SCALAR",
          "name": "DateTime",
          "description": "",
          "fields": null,
          "inputFields": null,
          "interfaces": null,
          "enumValues": null,
          "possibleTypes": null
        },
        ...
      ],
      "directives": [
        ...
      ]
    }
  }
}

Create Schema Definition from Introspection Result

Document schema = new IntrospectionResultToSchema().createSchemaDefinition((Map<String, Object>) introspectionResult.get("data"));
String printedSchema = new SchemaPrinter().print(schema);
Reader schemaProvider = new StringReader(printedSchema);
SchemaParser parser = new SchemaParser();
SchemaGenerator schemaGenerator = new SchemaGenerator();
TypeDefinitionRegistry typeRegistry = parser.parse(schemaProvider);
GraphQLSchema schema = schemaGenerator.makeExecutableSchema(typeRegistry, RuntimeWiring.newRuntimeWiring().build());

Error

The input value type ‘DateTime’ is not present when resolving type ‘UserWhereInput’ [@1107:1], There is no type resolver defined for interface / union ‘Node’ type

Does anyone have any idea or tries to implement this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
IceBlizz6commented, Jun 17, 2020

Nevermind, figured out the solution. SchemaPrinter(SchemaPrinter.Options.defaultOptions().includeScalarTypes(true)) Looks like SchemaPrinter does not print custom scalars by default.

0reactions
IceBlizz6commented, Jun 17, 2020

Suspect that i’m having the same problem. GraphQL introspection query gives information about scalar types. But SchemaPrinter().print(GraphQLSchema) output does not give any scalars. Even though it references Long and LocalDateTime types, they have no “scalar Long” definition.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom scalars - Apollo GraphQL Docs
Defining a custom scalar​​ You can now use MyCustomScalar in your schema anywhere you can use a default scalar (e.g., as the type...
Read more >
Maven Plugin Goals | GraphQL Kotlin
GraphQL Kotlin Maven Plugin provides functionality to generate a lightweight GraphQL HTTP client and generate GraphQL schema directly from ...
Read more >
Schemas | Caliban
Meaning that caliban will ignore the outer type and take the first case class parameter as the real type. If isScalar is true,...
Read more >
What you need to know about GraphQL enums
Let's make our GraphQL Schema more robust by migrating to enums. How to use enums. GraphQL enums can be defined using the enum...
Read more >
GraphQL specification
When representing a GraphQL schema using the type system definition language, the built‐in scalar types should be omitted for brevity. Result Coercion. A ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found