You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a query with variables inside array literal, an error Variable "$varName" is not defined by operation "Query_fieldName".. For example,
# With this schemaextendtypeQuery {
searchUsers (ids: [ID!]!): [User]
}
# The following query failsquerysearch($userId: ID!) {
searchUsers(ids: [$userId]) {
id
}
}
Operations like these work on Apollo Server. When I added a similar query into the base mercurius repo's tests, it also passes. Only in mercurius-gateway it fails.
The following test fails.
test('It support variable inside array literal',asynct=>{constusers=[{id: 'u1',name: {firstName: 'John',lastName: 'Doe'}},{id: 'u2',name: {firstName: 'Jane',lastName: 'Doe'}}]const[userService,userServicePort]=awaitcreateService(t,` directive @customDirective on FIELD_DEFINITION extend type Query { searchUsers (ids: [ID!]!): [User] } type User @key(fields: "id") { id: ID! name: UserName! } type UserName { firstName: String! lastName: String! } `,{Query: {searchUsers: (root,args)=>{returnusers.filter((u)=>args.ids.includes(u.id))}}})constgateway=Fastify()t.teardown(async()=>{awaitgateway.close()awaituserService.close()})awaitgateway.register(plugin,{gateway: {services: [{name: 'user',url: `http://localhost:${userServicePort}/graphql`}]}})constquery=` query MainQuery( $userId: ID! ){ searchUsers (ids: [$userId]) { id name { firstName lastName } } }`constres=awaitgateway.inject({method: 'POST',headers: {'content-type': 'application/json'},url: '/graphql',body: JSON.stringify({
query,variables: {userId: 'u1'}})})t.same(JSON.parse(res.body),{data: {searchUsers: [users[0]]}})})
The text was updated successfully, but these errors were encountered:
Sorry for the direct ping @mcollina, we'd appreciate any insights as to what may possibly be responsible for this issue.
We're happy to help investigate and fix this. Any direction will be helpful as we'd love to use Mercurius, but this is currently a blocker for us to adopting it fully.
When running a query with variables inside array literal, an error
Variable "$varName" is not defined by operation "Query_fieldName".
. For example,Operations like these work on Apollo Server. When I added a similar query into the base mercurius repo's tests, it also passes. Only in mercurius-gateway it fails.
The following test fails.
The text was updated successfully, but these errors were encountered: