Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from graphql.core import graphql
- from graphql.core.type import (
- GraphQLObjectType,
- GraphQLField,
- GraphQLString,
- )
- humanType = GraphQLObjectType(
- 'Human',
- description='A humanoid creature in the Star Wars universe.',
- fields=lambda: {
- 'id': GraphQLField(
- GraphQLNonNull(GraphQLString),
- resolver=lambda human, *_: 'random id',
- ),
- 'name': GraphQLField(
- GraphQLString,
- resolver=lambda human, *_: 'random name',
- ),
- },
- )
- StarWarsSchema = GraphQLSchema(query=humanType)
- query = '''
- query HeroNameQuery {
- id
- name
- }
- '''
- expected = {
- 'name': 'random name',
- 'id': 'random id',
- }
- result = graphql(StarWarsSchema, query)
- # assert not result.errors
- # assert result.data.keys() == ['id','name']
- print result.data
- # Result.data should be {'name': 'random name', 'id': 'random id'}
- # Instead of {'id': 'random id', 'name': 'random name'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement