Created
May 3, 2018 06:22
-
-
Save ddialar/fec4896c77d69660818a8d6916874899 to your computer and use it in GitHub Desktop.
Phone Number type definition for GraphQL back-end.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
GraphQLObjectType, | |
GraphQLInputObjectType, | |
GraphQLString, | |
GraphQLNonNull | |
} from 'graphql'; | |
var ObjectType = new GraphQLObjectType({ | |
name: 'PhoneNumber', | |
fields: () => ({ | |
number: { type: new GraphQLNonNull(GraphQLString) }, | |
description: { type: GraphQLString } | |
}) | |
}); | |
var InputType = new GraphQLInputObjectType({ | |
name: 'PhoneNumberInput', | |
fields: () => ({ | |
number: { type: new GraphQLNonNull(GraphQLString) }, | |
description: { type: GraphQLString } | |
}) | |
}); | |
export { | |
ObjectType, | |
InputType | |
}; |
Thanks! I'm New in graphql so Haven't much Idea about it. Found your content for the phone number so I asked.
Just a suggestion, try to look for up-to-date content. The post where I used that gist was typed long time ago and related tasks are not done this way right now.
I've been checking and Apollo Server repository was create on April 17, 2016 and this gist code was created on August 27, 2017.
In that date Apollo Server was irrelevant yet.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Apollo we use
.graphql
or.gql
schema definitions.If you pay attention to the code, I'm using the raw
graphql
library and this code is focused on being used withgraphql-express
. No one has mentioned Apollo any where.As you surely already know, depending on the tool you use in order to implement your GraphQL server, the schema definition is going to be different.
This code only shows the most basic way that it existed three years ago. Obviously, to implement a server this way has no sense nowadays.