We are releasing GraphQL builder 2.x for VTEX IO apps. Version 1.x will be deprecated. The GraphQL builder handles GraphQL schemas, used in API implementations for service apps.
Version 2.x requires all queries to use the @auth directive, enhancing security for apps using GraphQL APIs.
What has changed?
The @auth directive is added to queries and mutations to determine the authorization required for users or apps.
In GraphQL builder 1.x, the @auth directive is optional and defines a License Manager resource and product. Users or apps need a role or policy that includes the resource or product defined by the directive. Without the @auth directive, the query is public by default.
GraphQL builder
1.xwill be deprecated on January 7, 2026. Existing apps built with version1.xwill continue to work, but you won't be able to create new apps or major versions of existing apps using version1.x. After the deprecation date, apps using builder1.xwill fail to build via link or publish.
With builder version 2.x, the @auth directive is mandatory and requires the scope argument, which accepts the following values:
PUBLIC: The query is public and doesn't require authorization.PRIVATE: The query is private and requires authorization for a specific License Manager resource and product. When usingPRIVATE, theproductCodeandresourceCodearguments are also mandatory.
If an app is built with GraphQL builder version 2.x and is missing the @auth directive, the VTEX IO CLI will display an error message in these cases:
- Any query or mutation lacks the
@authdirective. - The
scopeargument is missing. - The
scopeisPRIVATE, andproductCodeorresourceCodearguments are missing.
An error occurred while loading the image ../../images/graphql-auth-directive-error.png
Why did we make this change?
This change enhances the security and transparency of GraphQL APIs in VTEX IO apps. Developers must now explicitly declare whether queries and mutations are public or require authorization within the schema.
What needs to be done?
To use the new builder version, developers must update their apps:
-
Update the GraphQL builder version to
2.xin the app's manifest._10"builders": {_10"graphql": "2.x",_10..._10}, -
Add the
@authdirective to every query and mutation in the app's GraphQL schema, and include thescopeargument. For public queries, use:_10type Query {_10source(id: ID!): String_10@auth(scope: PUBLIC)_10}For private queries, include the authorization requirements:
_10type Query {_10book(id: ID!): Book_10@auth(scope: PRIVATE, productCode: "64", resourceCode: "read_account_config")_10}
For more information, see GraphQL builder and GraphQL authorization in IO apps.