> Note: > The REST Admin API is a legacy API as of October 1, 2024. All apps and integrations should be built with the [GraphQL Admin API](/docs/api/admin-graphql). For details and migration steps, visit our [migration guide](/docs/apps/build/graphql/migrate). You can simplify GraphQL queries and mutations by extracting data into separate variables. GraphQL variables let you reuse the same requests with different arguments. ## Variable structure GraphQL requests can be split into query and variable sections. ### Query section In the query section, GraphQL variables begin with the `$` symbol and are declared after the `query` or `mutation` keyword, similar to passing an argument to a function. When you declare a variable, you need to specify its type, such as [`CustomerInput`](/docs/api/admin-graphql/latest/input-objects/CustomerInput). This lets GraphQL know that you intend to refer to this type by this variable name later in the actual query. For example, the following query declares an `$input` variable and passes it to the `input` argument: ```graphql mutation($input: CustomerInput!) { customerCreate(input: $input) { ... } } ``` ### Variable section In the variable section, variables are defined as a JSON object. The following JSON object defines the `$input` variable for the query section: ```json { "input": { "firstName": "Ayumu", "lastName": "Hirano", "email": "ayumu@example.com" } } ``` ## Simplify the customer creation request The following example simplifies the [`customerCreate` mutation example](/docs/apps/build/graphql/basics/mutations#example-create-a-customer) by using variables, resulting in an abstracted mutation that can be reused to create multiple customers. ```graphql mutation ($input: CustomerInput!) { customerCreate(input: $input) { customer { id displayName } userErrors { field message } } } ``` ```json { "input": { "firstName": "Ayumu", "lastName": "Hirano", "email": "ayumu@example.com" } } ``` ```json { "data": { "customerCreate": { "customer": { "id": "gid://shopify/Customer/1310038130710", "displayName": "Ayumu Hirano" }, "userErrors": [] } } ... } ``` ## Next steps Learn how to optimize your GraphQL implementation further with [inline fragments and multi-query requests](/docs/api/usage/graphql-basics/advanced).