Graphene: define schema using GraphQL DSL

Created on 4 Apr 2018  路  3Comments  路  Source: graphql-python/graphene

Hi, can I use graphene and define my GraphQL Schema directly by GraphQL DSL? Just like graphql-tools from Apollo Nodejs. https://github.com/apollographql/apollo-tutorial-kit/blob/server-tutorial-solution-Nov2017/data/schema.js#L3-L26

I think there's no need to expose the Graphene-specific schema definition above the language-agnostic GraphQL DSL to end-users.

Thanks.

Most helpful comment

Hi @jkimbo

I'm quite confused that why there are two types of definition. Graphene schema definition graphene.types.schema.Schema and graphql-core schema definition graphql.type.schema.GraphQLSchema.

Since graphene.types.schema.Schema is extended from graphql.type.schema.GraphQLSchema, how could I get graphene.types.schema.Schema from graphq.parse(DSL file)?

All 3 comments

Hi @mingzhou ,

There is already an open issue about this https://github.com/graphql-python/graphene/issues/448 where @jasonphillips has example of how it can work https://github.com/graphql-python/graphene/issues/448#issuecomment-356777997

However I don't think that allowing you to build a schema using the DSL is in the scope of this project. Graphene is an opinionated framework on how to build a GraphQL server in Python and so a solution that uses the GraphQL SDL language probably lives outside this project. I would be really interested in seeing a solution to that though.

Hi @jkimbo

I'm quite confused that why there are two types of definition. Graphene schema definition graphene.types.schema.Schema and graphql-core schema definition graphql.type.schema.GraphQLSchema.

Since graphene.types.schema.Schema is extended from graphql.type.schema.GraphQLSchema, how could I get graphene.types.schema.Schema from graphq.parse(DSL file)?

I think that using this new library solves the problem:
https://graphql-core-next.readthedocs.io/en/latest/usage/sdl.html

Was this page helpful?
0 / 5 - 0 ratings