Created
August 5, 2018 14:09
-
-
Save ermik/db18c7cc7ec98680844e3fd90affeca9 to your computer and use it in GitHub Desktop.
Ignoring
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
// There are existing structs for Request -> Response dataflow as well as | |
// a struct for the Product; | |
// | |
// In this case we are mapping the Input type to a Request type see yaml and grapqql files | |
// | |
// Here's the struct we map to: | |
type CreateProductRequest struct { | |
Name string `json:"name"` | |
GTIN string `json:"gtin"` | |
Description string `json:"description"` | |
} | |
// You can see that there is no mapping possible for 'clientMutationId' | |
// In fact, this type is returned back to the caller, so it should be preserved | |
// during query execution — in a resolver function mapping from CreareProductRequest | |
// to a generated 'CreateProductPayload' |
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
models: | |
CreateProductInput: | |
fields: | |
clientMutationId: | |
resolver: true | |
model: <proprietary_repo>/endpoints.CreateProductRequest |
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 Product implements Node { | |
"""The ID of an object""" | |
id: ID! | |
} | |
type Query { | |
getProductsByName(name: String!, before: String, after: String, first: Int, last: Int): ProductConnection | |
"""Fetches an object given its Globally Unique ID""" | |
node( | |
"""The ID of the object""" | |
id: ID! | |
): Node | |
} | |
type Mutation { | |
createProduct(input: CreateProductInput): CreateProductPayload | |
} | |
input CreateProductInput { | |
clientMutationId: String! | |
name: String! | |
gtin: String! | |
description: String! | |
} | |
type CreateProductPayload { | |
clientMutationId: String! | |
edge: ProductEdge | |
} | |
"""An object with a Globally Unique ID""" | |
interface Node { | |
"""The ID of the object.""" | |
id: ID! | |
} | |
type ProductConnection { | |
"""Information to aid in pagination.""" | |
edges: [ProductEdge] | |
"""Information to aid in pagination.""" | |
pageInfo: PageInfo! | |
} | |
type ProductEdge { | |
"""cursor for use in pagination""" | |
cursor: String! | |
"""The item at the end of the edge""" | |
node: Product | |
} | |
"""Information about pagination in a connection.""" | |
type PageInfo { | |
"""When paginating forwards, the cursor to continue.""" | |
endCursor: String | |
"""When paginating forwards, are there more items?""" | |
hasNextPage: Boolean! | |
"""When paginating backwards, are there more items?""" | |
hasPreviousPage: Boolean! | |
"""When paginating backwards, the cursor to continue.""" | |
startCursor: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment