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 { | |
GraphQLSchema, | |
GraphQLObjectType, | |
} from 'graphql'; | |
import { | |
userQueries, | |
userMutations, | |
} from './users/users'; |
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 { | |
GraphQLString, | |
GraphQLID, | |
GraphQLInputObjectType, | |
GraphQLObjectType, | |
} from 'graphql'; | |
export const UserType = new GraphQLObjectType({ | |
name: 'UserType', | |
description: 'User type definition', |
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 { | |
GraphQLList, | |
GraphQLNonNull, | |
} from 'graphql'; | |
import { | |
internet, | |
random, | |
} from 'faker'; |
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
query { | |
users { | |
id, | |
} | |
} |
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
mutation { | |
createUser(userPayload: { | |
email: "david@atheros.ai" | |
}) { | |
id, | |
} | |
} |
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 express from 'express'; | |
import graphqlHTTP from 'express-graphql'; | |
import schema from './graphql/schema'; | |
const app = express(); | |
const dev = process.env.NODE_ENV === 'development'; | |
app.use('/graphql', graphqlHTTP({ |
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 { | |
GraphQLString, | |
GraphQLID, | |
GraphQLObjectType, | |
GraphQLNonNull, | |
} from 'graphql'; | |
const UserType = new GraphQLObjectType({ | |
name: 'User', | |
description: 'User type definition', |
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
type User { | |
id: ID! | |
username: String! | |
email: String | |
phone: String | |
firstName: String | |
lastName: String | |
} |
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
const userMutations = { | |
createUser: { | |
type: UserType, | |
args: { | |
input: { | |
type: new GraphQLNonNull(UserInputType), | |
}, | |
}, | |
resolve: async (rootValue, { input }) => { |
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
mutation createUser { | |
createUser(input: { | |
username: "test", | |
email: "test@test.cz", | |
phone: "479332973", | |
firstName: "David", | |
lastName: "Test" | |
}) { | |
user { | |
id |
OlderNewer