Differences from GraphQL.js
Direct attribute access in GraphQL types
You can access
the fields of GraphQLObjectTypes, GraphQLInterfaceTypes and GraphQLInputObjectTypes,
the interfaces of GraphQLObjectTypes,
the types of GraphQLUnionTypes,
the values of GraphQLEnumTypes and
the query, mutation, subscription and type_map of GraphQLSchemas
directly as attributes, instead of using getters.
For example, to get the fields of a GraphQLObjectType
obj, you write
obj.fields instead of
Arguments, fields and values are dictionaries
The arguments of GraphQLDirectives and GraphQLFields,
the fields of GraphQLObjectTypes, GraphQLInterfaceTypes and GraphQLInputObjectTypes, and
the values of GraphQLEnumTypes
are always Python dictionaries in GraphQL-core, while they are returned as Arrays in GraphQL.js. Also, the values of these dictionaries do not have
name attributes, since the names are already used as the keys of these dictionaries.
Shorthand notation for creating GraphQL types
The following shorthand notations are possible:
Where you need to pass a GraphQLArgumentMap, i.e. a dictionary with names as keys and GraphQLArguments as values, you can also pass GraphQLInputTypes as values. The GraphQLInputTypes are then automatically wrapped into GraphQLArguments.
Where you need to pass a GraphQLFieldMap, i.e. a dictionary with names as keys and GraphQLFields as values, you can also pass GraphQLOutputTypes as values. The GraphQLOutputTypes are then automatically wrapped into GraphQLFields.
Where you need to pass a GraphQLInputFieldMap, i.e. a dictionary with names as keys and GraphQLInputFields as values, you can also pass GraphQLInputTypes as values. The GraphQLInputTypes are then automatically wrapped into GraphQLInputFields.
Where you need to pass a GraphQLEnumValueMap, i.e. a dictionary with names as keys and GraphQLEnumValues as values, you can pass any other Python objects as values. These will be automatically wrapped into GraphQLEnumValues. You can also pass a Python Enum type as GraphQLEnumValueMap.
Custom output names of arguments and input fields
You can pass a custom
out_name argument to
Custom output types of input object types
You can also pass a custom
out_type argument to
GraphQLInputObjectType that allows conversion to any Python type on egress instead of conversion to a dictionary, which is the default. This is used to support the container feature of Graphene InputObjectTypes.
execute() function takes an additional
middleware argument which must be a sequence of middleware functions or a
MiddlewareManager object. This feature is used by Graphene to affect the evaluation of fields using custom middleware. There has been a request to add this to GraphQL.js as well, but so far this feature only exists in GraphQL-core.
Custom execution context
Registering special types for descriptions
Normally, descriptions for GraphQL types must be strings. However, sometimes you may want to use other kinds of objects which are not strings, but are only resolved to strings at runtime. This is possible if you register the classes of such objects with
If you notice any other important differences, please let us know so that they can be either removed or listed here.