Use a Namespace Prefix

To package your components and distribute them on AppExchange, use a Developer Edition organization and register a namespace prefix. The namespace prefix prevents naming conflicts in the installer's organization.

Just like component names include a namespace prefix in managed packages, GraphQL API queries in your components must include a namespace prefix on custom objects and fields.

If your org uses a namespace, namespacing is resolved automatically for custom objects and fields in your query even if your query doesn’t include them.

If you’re referencing objects and fields from another namespace, include the namespace in your query using the format namespace__MyCustomObject__c and namespace__MyCustomField__c.

When a package is installed outside of a namespace, the query is updated with namespace substitution for the custom objects and fields. Referential integrity is preserved and the substitutions don't affect the request and response body of the query in the package.

When the managed package is installed in an org, a prefix is added to custom objects and fields without a namespace prefix.

Let's say this query is from a namespaced package.

When the managed package is installed in an org outside the original namespace, the query implements namespace substitution for custom objects and fields.

To preserve referential integrity and prevent naming conflicts, the resulting query includes GraphQL aliasing syntax.

References to objects and fields outside of the gql template literal aren’t updated.

Use Aliases with Custom Objects and Fields

Second-Generation Managed Packages

Salesforce DX Project Configuration