I am working on a modularized Graphql schema using Python with Ariadne. I start with a base schema file, such as "Main.graphql":
type Query
{ doSomethingUseless: String!}
In another schema file like po.graphql I would have:
type poData
{
...
}
extend type Query
{ poByNbr(poNbr: String!): poData!}
Is there a way to incorporate variables into the modularized schema? As far as I can tell, variables have to be declared with the query object declaration, such as
query poByNbr($poNbr: String!)
{
po( nbr: $poNbr)
}
However, this does not work with an 'extends' syntax. For example,
extend type Query ($poNbr: String!)
{ poByNbr($poNbr): poData! }
is invalid syntax. Am I missing something, or is this type of schema modularization incompatible with using variables?
Variables are used in queries, mutations and subscriptions, to avoid hardcoding the input values for field arguments in an operation. They are substituted with the passed values at runtime when the operation is executed.
Variables do not exist at all in a schema where you define (or extend) your types.
You are not missing anything, variable syntax is not part of the schema definition language and is very much incompatible with it.