graphql#ValidationContext TypeScript Examples

The following examples show how to use graphql#ValidationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: validation.ts    From amplify-codegen with Apache License 2.0 6 votes vote down vote up
export function NoAnonymousQueries(context: ValidationContext) {
  return {
    OperationDefinition(node: OperationDefinitionNode) {
      if (!node.name) {
        context.reportError(new GraphQLError('Apollo does not support anonymous operations', [node]));
      }
      return false;
    },
  };
}
Example #2
Source File: validation.ts    From amplify-codegen with Apache License 2.0 6 votes vote down vote up
export function NoTypenameAlias(context: ValidationContext) {
  return {
    Field(node: FieldNode) {
      const aliasName = node.alias && node.alias.value;
      if (aliasName == '__typename') {
        context.reportError(
          new GraphQLError('Apollo needs to be able to insert __typename when needed, please do not use it as an alias', [node])
        );
      }
    },
  };
}