luckycatfactory / esbuild-graphql-loader

An esbuild Plugin Allowing for GraphQL File imports
44 stars 8 forks source link

Named imports nor working from large schema.graphql #29

Open jschuur opened 2 years ago

jschuur commented 2 years ago

I have a large schema.graphql file (generated by KeystoneJS) and thought I could just import a single mutation from it as a named import, but I'm getting an error that it couldn't be found:

No matching export in "schema.graphql" for import "updateDeployments"

Here's my test code:

import { GraphQLClient } from 'graphql-request';

import { updateDeployments } from '../../schema.graphql';
import { authenticateUser } from '../graphql/graphqlMutations';

const graphQLClient = new GraphQLClient(process.env.GRAPHQL_API_ENDPOINT);

(async () => {
  await authenticateUser(graphQLClient, { email: process.env.GRAPHQL_USER, password: process.env.GRAPHQL_PASSWORD });

  const res = await graphQLClient.request(updateDeployments, {
    data: { where: { id: { equals: 'a51d87d7-29c9-4e19-98c0-db766190edc5' } }, data: { status: 'pending' } },
  });
  console.log(res);
})();

The mutatio is listed in a block with a lot of others:

...
type Mutation {
  ...
  updateDeployments(data: [DeploymentUpdateArgs!]!): [Deployment]
  ...
}
...

Should this work? I've succesfully used the plugin when importing a mutation from a file where only one is defined.

I'm using v3.7.0.