How to use the graphql-compose.schemaComposer.createObjectTC function in graphql-compose

To help you get started, we’ve selected a few graphql-compose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nodkz / conf-talks / articles / graphql / schema-build-ways / graphql-compose.js View on Github external
// @flow

import { ApolloServer } from 'apollo-server';
import { schemaComposer } from 'graphql-compose';
import { authors, articles } from './data';

const AuthorType = schemaComposer.createObjectTC(`
  "Author data"
  type Author {
    id: Int
    name: String
  }
`);

const ArticleType = schemaComposer.createObjectTC({
  name: 'Article',
  description: 'Article data with related Author data',
  fields: {
    title: 'String!',
    text: 'String',
    authorId: 'Int!',
    author: {
      type: () => AuthorType,
github graphql-compose / graphql-compose-connection / src / __mocks__ / rootQueryTC.js View on Github external
/* @flow */

import { schemaComposer } from 'graphql-compose';

export const rootQueryTC = schemaComposer.createObjectTC({
  name: 'RootQuery',
  fields: {},
});
github nodkz / conf-talks / articles / graphql / schema-build-ways / graphql-compose.js View on Github external
// @flow

import { ApolloServer } from 'apollo-server';
import { schemaComposer } from 'graphql-compose';
import { authors, articles } from './data';

const AuthorType = schemaComposer.createObjectTC(`
  "Author data"
  type Author {
    id: Int
    name: String
  }
`);

const ArticleType = schemaComposer.createObjectTC({
  name: 'Article',
  description: 'Article data with related Author data',
  fields: {
    title: 'String!',
    text: 'String',
    authorId: 'Int!',
    author: {
      type: () => AuthorType,
      resolve: source => {
        const { authorId } = source;
        return authors.find(o => o.id === authorId);
      },
    },
  },
});
github graphql-compose / graphql-compose-aws / src / AwsServiceMetadata.js View on Github external
getTypeComposer(): ObjectTypeComposer {
    if (!this.tc) {
      this.tc = schemaComposer.createObjectTC(`
        type ${this.getPrefix()}Metadata {
          apiVersion: String
          endpointPrefix: String
          globalEndpoint: String
          serviceAbbreviation: String
          serviceFullName: String
          signatureVersion: String
          uid: String
          raw: JSON
        }
      `);
    }
    return this.tc;
  }
github graphql-compose / graphql-compose-aws / src / AwsParam.js View on Github external
shapes?: AwsShapes
  ): ObjectTypeComposer {
    const fields = {};

    if (param.members) {
      Object.keys(param.members).forEach(fname => {
        fields[fname] = this.convertParam(
          param.members[fname],
          `${name}${upperFirst(fname)}`,
          false,
          shapes
        );
      });
    }

    const tc = schemaComposer.createObjectTC({
      name,
      fields,
    });

    if (Array.isArray(param.required)) {
      tc.makeFieldNonNull(param.required);
    }

    return tc;
  }
github graphql-compose / graphql-compose-aws / src / AwsService.js View on Github external
getTypeComposer(): ObjectTypeComposer {
    if (!this.tc) {
      const fields = this.getOperationNames().reduce((res, name) => {
        res[this.constructor.lowerFirst(name)] = this.getOperation(name).getFieldConfig();
        return res;
      }, {});

      this.tc = schemaComposer.createObjectTC({
        name: this.getTypeName(),
        fields,
        description: this.metadata.getDescription(),
      });
    }
    return this.tc;
  }
github graphql-compose / graphql-compose-connection / src / __mocks__ / userTC.js View on Github external
id: {
      type: GraphQLInt,
    },
    name: {
      type: GraphQLString,
    },
    age: {
      type: GraphQLInt,
    },
    gender: {
      type: GraphQLString,
    },
  },
});

export const userTC = schemaComposer.createObjectTC(UserType);

export const userList = [
  { id: 1, name: 'user01', age: 11, gender: 'm' },
  { id: 2, name: 'user02', age: 12, gender: 'm' },
  { id: 3, name: 'user03', age: 13, gender: 'f' },
  { id: 4, name: 'user04', age: 14, gender: 'm' },
  { id: 5, name: 'user05', age: 15, gender: 'f' },
  { id: 6, name: 'user06', age: 16, gender: 'f' },
  { id: 7, name: 'user07', age: 17, gender: 'f' },
  { id: 8, name: 'user08', age: 18, gender: 'm' },
  { id: 9, name: 'user09', age: 19, gender: 'm' },
  { id: 10, name: 'user10', age: 49, gender: 'f' },
  { id: 11, name: 'user11', age: 49, gender: 'm' },
  { id: 12, name: 'user12', age: 47, gender: 'f' },
  { id: 15, name: 'user15', age: 45, gender: 'm' },
  { id: 14, name: 'user14', age: 45, gender: 'm' },