This file contains hidden or 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 { | |
post { | |
title | |
} | |
} |
This file contains hidden or 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
{ | |
"title": "GraphQL", | |
"body": "GraphQL is amazing due to these fundamental principles", | |
"author": "Shailen Naidoo", | |
"tags": ["graphql", "apis", "rest", "api"] | |
} |
This file contains hidden or 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 { createTypeQuery } from './query'; | |
import Types from './types'; | |
const realTypeQuery = createTypeQuery({ _: Types.BooleanNull }); | |
const testTypeQuery = gql` | |
type Query { | |
_: ${Types.BooleanNull} | |
} | |
`; |
This file contains hidden or 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 { createTypeQueryPerson, createTypePerson, Person } from './person'; | |
import Types from './types'; | |
const typePerson = createTypePerson({ name: Types.StringNonNull, surname: Types.StringNonNull }); | |
const typeQueryPerson = createTypeQueryPerson({ person: Person.Type }); | |
export default [typePerson, typeQueryPerson]; |
This file contains hidden or 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 { gql } from 'apollo-server-express'; | |
import { DocumentNode } from 'graphql' | |
import Types from './types'; | |
export enum Person { | |
Type: 'Person!' | |
} | |
interface TypePersonFields { | |
name: Types.StringNonNull; |
This file contains hidden or 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 { gql } from 'apollo-server-express'; | |
import { DocumentNode } from 'graphql' | |
import Types from './types'; | |
interface TypeQueryFields { | |
_: Types.BooleanNull | |
} | |
export const createTypeQuery = ({ _ }: TypeQueryFields): DocumentNode => gql` | |
type Query { |
This file contains hidden or 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
enum Types { | |
IDNull = 'ID', | |
IDNonNull = 'ID!', | |
StringNull = 'String', | |
StringNonNull = 'String!', | |
IntNull = 'Int', | |
IntNonNull = 'Int!', | |
FloatNull = 'Float', | |
FloatNonNull = 'Float!', | |
BooleanNull = 'Boolean', |
This file contains hidden or 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 { gql } = require('apollo-server-express'); | |
const { typeQuery, typePerson } = require(./index); | |
test('check if type Query has correct fields', () => { | |
expect(typeQuery).toBe(gql` | |
type Query { | |
_: Boolean | |
} | |
`); | |
}); |
This file contains hidden or 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 { gql } = require('apollo-server-express'); | |
const typeQuery = gql` | |
type Query { | |
_: Boolean | |
} | |
`; | |
const typePerson = gql` | |
type Person { |
This file contains hidden or 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 { gql } = require('apollo-server-express'); | |
const Schema = gql` | |
type Query { | |
person: Person! | |
} | |
type Person { | |
name: String! | |
surname: String! |