mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright 2013-2015, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
import {
|
|
GraphQLObjectType,
|
|
GraphQLSchema,
|
|
GraphQLString,
|
|
} from 'graphql';
|
|
|
|
|
|
var GREETINGS = {
|
|
hello: 'Hello worlasdfasdfasssdfasdfasdasdd',
|
|
};
|
|
|
|
/**
|
|
* Objects.
|
|
* Build up a portrait of your data universe
|
|
* using the object type. Here, we define a
|
|
* type of object that has a 'hello' field
|
|
* that is of the string type.
|
|
*/
|
|
var GreetingsType = new GraphQLObjectType({
|
|
name: 'Greetings',
|
|
fields: () => ({
|
|
hello: {type: GraphQLString},
|
|
}),
|
|
});
|
|
|
|
/**
|
|
* The schema.
|
|
* Here we export a schema that offers one root
|
|
* field named 'greetings', and a method to
|
|
* resolve its data.
|
|
*
|
|
* To learn more about writing GraphQL schemas for Relay, visit:
|
|
* https://github.com/graphql/graphql-relay-js
|
|
*/
|
|
export default new GraphQLSchema({
|
|
query: new GraphQLObjectType({
|
|
name: 'Query',
|
|
fields: () => ({
|
|
greetings: {
|
|
type: GreetingsType,
|
|
// Here we define a resolver that returns
|
|
// the data defined above. Were this schema
|
|
// executing on the server side, you could
|
|
// write a resolve method that fetches
|
|
// live data from a database.
|
|
resolve: () => GREETINGS,
|
|
},
|
|
}),
|
|
}),
|
|
});
|