Last active
April 4, 2019 21:02
-
-
Save tgroshon/ab4b19b0db36324f3e7f7773ae591340 to your computer and use it in GitHub Desktop.
Example GraphQL Schema
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
# These are your main API Types | |
type User { | |
id: ID! | |
name: String! | |
email: AWSEmail | |
} | |
type Activity { | |
id: ID! | |
title: String! | |
description: String | |
location: Location | |
creator: User | |
notes: [ActivityNote] | |
costCodes: [CostCodes] | |
} | |
type Location { | |
lat: Float! | |
long: Float! | |
} | |
type ActivityNote { | |
date: AWSDate | |
author: User | |
content: String | |
} | |
type CostCodes { | |
id: ID! | |
description: [String] | |
} | |
# The kinds of reads you can do | |
type Query { | |
getUser(id: ID!) User | |
listUsers(emailFilter: AWSEmail) [User] | |
getActivity(id: ID!) Activity | |
listActivities(locationFilter: Location) [Activity] | |
} | |
# The kinds of creates, updates, and deletes you can do | |
type Mutation { | |
addUser(name: String!, email: AWSEmail) User | |
addActivity(title: String!, description: String, location: Location) Activity | |
} | |
# Declares your API schema | |
schema { | |
query: Query | |
mutation: Mutation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A more complicated/interesting query:
This will return Activities with the creator as a sub-object, the notes as a list of notes, and the author of each note as a sub-object on each note. All in one query.