0% found this document useful (0 votes)
40 views1 page

Graph QL

Uploaded by

Shopre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views1 page

Graph QL

Uploaded by

Shopre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

### What is GraphQL?

GraphQL is a query language for APIs and a runtime for executing queries
against your data.

#### Key Concepts:


1. **Queries**: Fetch data.
```graphql
query {
user(id: 1) {
name
email
}
}

2. Mutations: Modify data.

graphql
CopyEdit
mutation {
updateUser(id: 1, name: "Alice") {
id
name
}
}

3. Schema: Defines the structure of the API.


4. Using with React:
o Use Apollo Client for integration.

javascript
CopyEdit
import { useQuery } from "@apollo/client";
const GET_USERS = gql`query { users { id name } }`;
const { loading, data } = useQuery(GET_USERS);

Benefits of GraphQL:

 Reduces over-fetching and under-fetching of data.


 Single endpoint for all queries and mutations.

You might also like