Skip to content

graphql_schema outputs graphQL SDL file with legacy syntax #1505

Open
@matt-dalton

Description

@matt-dalton

What is the current behavior?
When I run the graphql_schema management function with a graphQL output (e.g. python manage.py graphql_schema --out schema.graphql) I get a schema that looks like:

type Mutation {
    addTodo(name: String!, priority: Priority = LOW): Todo!
    removeTodo(id: ID!): Todo!
}

schema {
    query: Query
    mutation: Mutation
}

type Viewer implements Node, ViewerBaseInterface {
    id: ID!
}

interface ViewerBaseInterface {
    otherField: String
}

interface Node {
    id: ID!
}

When I tried to use the Relay compiler to generate types using this schema, it kept throwing an obscure error ([INFO] [default] compiling... [ERROR] ✖︎ Expected a end of file <generated>: <missing source> for anyone struggling with this)

After much debugging, I discovered this line was the problem:
type Viewer implements Node, ViewerBaseInterface

The issue is with the comma syntax to denote inheritance from multiple interfaces. This syntax should now look like type Viewer implements Node & ViewerBaseInterface.

This issue is described on the Relay side here. The fix is to update the schema generation to a later version (in JS this version is graphql-js v0.13).

What is the expected behavior?
We are unfortunately still on Graphene v2.1.9/Graphene-django 2.16.0. We are planning to upgrade later in the year but this will be a fairly large undertaking for us. Because of this I'm not sure if Graphene v3 fixes the issue.

Either way, would it be possible to release a v2 version with the new syntax generator to allow us/others to work around this issue?
Alternatively is there another way we can work round this in the short-term? e.g. what dependency should we update if we wanted to create a fork?

What is the motivation / use case for changing the behavior?
Supporting new graphQL behaviour on v2

Please tell us about your environment:

  • Version:
    graphene = "2.1.9"
    graphene-django = "2.16.0"
  • Platform: mac

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
Similar issue with a different library: https://stackoverflow.com/questions/49198778/relay-compiler-cannot-compile-graph-cool-graphql-schemas-with-multiple-inheritan

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions