这是indexloc提供的服务,不要输入任何密码
Skip to content

v1.0.0-alpha32 breaks graphql-tools makeRemoteExecutableSchema #1243

@szhang-ezypay

Description

@szhang-ezypay

Hi

I have setup several hasura servers for my postgres databases. Then I use apollo server to do schema stitching and transforming. Everything worked fine until version v1.0.0-alpha32.

old schema.txt
new schema.txt

The error message is:

{ GraphQLError: Syntax Error: Expected Name, found }
    at syntaxError (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/error/syntaxError.js:24:10)
    at expect (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:1299:32)
    at parseName (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:92:15)
    at parseInputValueDef (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:842:14)
    at many (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:1348:16)
    at parseInputFieldsDefinition (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:992:50)
    at parseInputObjectTypeDefinition (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:977:16)
    at parseTypeSystemDefinition (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:671:16)
    at parseDefinition (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:143:16)
    at parseDocument (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/language/parser.js:110:22)
  message: 'Syntax Error: Expected Name, found }',
  locations: [ { line: 73, column: 1 } ],
  path: undefined }
(node:15732) UnhandledPromiseRejectionWarning: Error: Query root type must be provided.
    at assertValidSchema (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/type/validate.js:82:11)
    at assertValidExecutionArguments (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/execution/execute.js:201:35)
    at executeImpl (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/execution/execute.js:136:3)
    at Object.execute (/home/szhang/Documents/playground/apollo-server-v2/node_modules/graphql/execution/execute.js:131:229)
    at Object.generateSchemaHash (/home/szhang/Documents/playground/apollo-server-v2/node_modules/apollo-server-core/dist/utils/schemaHash.js:14:32)
    at new ApolloServerBase (/home/szhang/Documents/playground/apollo-server-v2/node_modules/apollo-server-core/dist/ApolloServer.js:175:40)
    at new ApolloServer (/home/szhang/Documents/playground/apollo-server-v2/node_modules/apollo-server-express/dist/ApolloServer.js:44:1)
    at Object.<anonymous> (/home/szhang/Documents/playground/apollo-server-v2/dist/server.js:118:20)
    at Generator.next (<anonymous>)
    at fulfilled (/home/szhang/Documents/playground/apollo-server-v2/dist/server.js:100:58)
(node:15732) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15732) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is my function to merge schemas.

const createRemoteExecutableSchemas = async () => {
  let schemas = [];
  const apis = endpoints();
  for (const key of Object.keys(apis)) {
    const link = new HttpLink({
      uri: apis[key],
      fetch,
      headers: {
        'x-hasura-access-key': process.env.HASURA_ACCESS_KEY,
      },
    });
    try {
      const remoteSchema = await introspectSchema(link);
      const remoteExecutableSchema = makeRemoteExecutableSchema({ schema: remoteSchema, link });

      const transformedSchema = transformSchema(remoteExecutableSchema, [
        new FilterRootFields((operation: string) => operation !== 'Mutation'),
        new RenameTypes((name: string) => `${key}_${name}`, { renameBuiltins: false, renameScalars: false }),
        new RenameRootFields((operation: 'Query' | 'Mutation' | 'Subscription', name: string) => `${key}_${name}`),
      ]);

      schemas.push(transformedSchema);
    } catch (error) {
      log.error(error);
    }
  }
  return schemas;
};

It failed on this line:
const remoteExecutableSchema = makeRemoteExecutableSchema({ schema: remoteSchema, link });

I believe the problem is the added input types which has empty body.

"""
order by stddev() on columns of table "customer"
"""
input customer_stddev_order_by {

}

Is this a bug? How can I get around this issue? Thanks

Metadata

Metadata

Assignees

Labels

c/serverRelated to servere/intermediatecan be wrapped up in a weekk/bugSomething isn't workingp/urgentImmediate action required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions