Graphql usage: Difference between revisions

From wikinotes
No edit summary
m (Will moved page Graphql: usage to Graphql usage without leaving a redirect)
(No difference)

Revision as of 02:32, 3 September 2021

Example

Graphql is a language, and it's schema is a large file defining all of the available types, queries, and mutations.

# query

curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"query":    "query { members($search: String){ firstName lastName } }", \
       "variables" { "search": "al*" }}' \
  example.com/graphql
# mutation

curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"query":  "mutation { createMember($firstName: String!, $lastName: String!){ ... } }", \
       "variables": { "firstName": "foo", "lastName": "bar" }}' \
  example.com/graphql