diff --git a/AppSync/GraphQL.md b/AppSync/GraphQL.md new file mode 100644 index 0000000..ce2bb7a --- /dev/null +++ b/AppSync/GraphQL.md @@ -0,0 +1,43 @@ +# GraphQL +GraphQL is an FOSS agnostic query adaptor that allows you to query data from many different data sources. GraphQL is used to build APIs where clients will send a query for nested data. GraphQL mitigates the issue of versioned or rapidly changing APIs compared to REST APIs because you can request the data you want. + +GraphQL schemas are written in the GraphQL SDL (Schema Definition Language) composed on: +- **Types**. Represent objects and their **fields**: +```graphql +type Query { + me: User +} + +type User { + id: ID + name: String +} +``` +- **Fields** +- **Queries**. Define the exact shape of the data needed by the client: +```graphql +query CurrentUser { + currentUser { + name + age + } +} +``` +- **Mutations**. Allow for data to be create, updated or deleted: +```graphql +mutation CreateUser($name: String!, $age: Int!) { + createUser(userName: $name, age: $age) { + name + age + } +} +``` +- **Subscriptions**. Supports live updates sent from the server to the client: +```graphql +subscription { + newPerson { + name + age + } +} +```