graphql#GraphQLSchemaConfig TypeScript Examples

The following examples show how to use graphql#GraphQLSchemaConfig. 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: soap-graphql.ts    From graphql-mesh with MIT License 6 votes vote down vote up
export async function soapGraphqlSchemaConfig(options: SoapGraphqlOptions): Promise<GraphQLSchemaConfig> {
  const soapClient: NodeSoapClient = await useSoapClient(options);
  const wsdl: SoapEndpoint = await createSoapEndpoint(soapClient, options.logger);

  if (!options.soapCaller) {
    options.soapCaller = new NodeSoapCaller(soapClient, options.logger);
  }

  return createSchemaConfig(wsdl, options.soapCaller, options.schemaOptions, options.logger);
}
Example #2
Source File: schema-resolver.ts    From graphql-mesh with MIT License 6 votes vote down vote up
resolve(): GraphQLSchemaConfig {
    this.outputResolver = new GraphqlOutputFieldResolver(this.options, this.logger);
    this.inputResolver = new GraphqlInputFieldResolver(this.options, this.logger);

    return {
      query: this.createQueryObject(),
      mutation: this.createMutationObject(),
    };
  }
Example #3
Source File: soap2graphql.ts    From graphql-mesh with MIT License 5 votes vote down vote up
export function createSchemaConfig(
  endpoint: SoapEndpoint,
  soapCaller: SoapCaller,
  options: SchemaOptions = {},
  logger: Logger
): GraphQLSchemaConfig {
  return new SchemaResolver(endpoint, soapCaller, options, logger).resolve();
}
Example #4
Source File: simple.ts    From graphql-sse with MIT License 5 votes vote down vote up
schemaConfig: GraphQLSchemaConfig = {
  query: new GraphQLObjectType({
    name: 'Query',
    fields: {
      getValue: {
        type: new GraphQLNonNull(GraphQLString),
        resolve: () => 'value',
      },
    },
  }),
  subscription: new GraphQLObjectType({
    name: 'Subscription',
    fields: {
      greetings: {
        type: new GraphQLNonNull(GraphQLString),
        subscribe: async function* () {
          for (const hi of ['Hi', 'Bonjour', 'Hola', 'Ciao', 'Zdravo']) {
            yield { greetings: hi };
          }
        },
      },
      ping: {
        type: new GraphQLNonNull(GraphQLString),
        args: {
          key: {
            type: GraphQLString,
          },
        },
        subscribe: function (_src, args) {
          const key = args.key ? args.key : 'global';
          return {
            [Symbol.asyncIterator]() {
              return this;
            },
            async next() {
              if ((pendingPongs[key] ?? 0) > 0) {
                // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
                pendingPongs[key]!--;
                return { value: { ping: 'pong' } };
              }
              if (
                await new Promise((resolve) => (pongListeners[key] = resolve))
              )
                return { done: true };
              return { value: { ping: 'pong' } };
            },
            async return() {
              pongListeners[key]?.(true);
              delete pongListeners[key];
              return { done: true };
            },
            async throw() {
              throw new Error('Ping no gusta');
            },
          };
        },
      },
    },
  }),
}