How to use the GraphQLInt function from graphql

Find comprehensive JavaScript graphql.GraphQLInt code examples handpicked from public code repositorys.

graphql.GraphQLInt is a built-in GraphQL type that represents an integer value.

8
9
10
11
12
13
14
15
16
17
function sqlTypeToGraphQL (sqlType) {
  // TODO support more types
  /* istanbul ignore next */
  switch (sqlType) {
    case 'int':
      return graphql.GraphQLInt
    case 'integer':
      return graphql.GraphQLInt
    case 'tinyint':
      return graphql.GraphQLBoolean
fork icon96
star icon963
watch icon17

+ 9 other calls in file

135
136
137
138
139
140
141
142
143
144
film: {
  type: Film,
  args: {
    id: {
      description: 'Fetch the film by id',
      type: graphql.GraphQLInt
    }
  },
  resolve: (root, args) => load_film(args.id)
}
fork icon34
star icon639
watch icon14

+ 3 other calls in file

How does graphql.GraphQLInt work?

GraphQLInt is a built-in scalar type in the graphql library that represents a 32-bit signed integer value, which can be used as a field or argument type in a GraphQL schema definition. It performs input validation to ensure the provided value is a valid integer, and it will also serialize/deserialize values as expected when sending/receiving data over the wire.

860
861
862
863
864
865
866
867
868
869
if (!withDeleted && itemColumns[i].name === "Deleted")
    continue;

switch (itemColumns[i].type) {
    case "int":
        t = graphql.GraphQLInt;
        break;
    case "decimal":
        t = graphql.GraphQLFloat;
        break;
fork icon3
star icon6
watch icon0

6
7
8
9
10
11
12
13
14
15
global.GraphqlList = global.GraphQLList = graphql.GraphQLList;
global.GraphqlNonNull = global.GraphQLNonNull = graphql.GraphQLNonNull;
global.GraphqlUnionType = global.GraphQLUnionType = graphql.GraphQLUnionType;
global.GraphqlInterfaceType = global.GraphQLInterfaceType = graphql.GraphQLInterfaceType;
global.GraphqlEnumType = global.GraphQLEnumType = graphql.GraphQLEnumType;
global.GraphqlInt = global.GraphQLInt = graphql.GraphQLInt;
global.GraphqlFloat = global.GraphQLFloat = graphql.GraphQLFloat;
global.GraphqlString = global.GraphQLString = graphql.GraphQLString;
global.GraphqlBoolean = global.GraphQLBoolean = graphql.GraphQLBoolean;
global.GraphqlID = global.GraphQLID = graphql.GraphQLID;
fork icon0
star icon0
watch icon5

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
const { GraphQLSchema, GraphQLObjectType, GraphQLInt } = require("graphql");

const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: "MyQuery",
    fields: {
      myField: {
        type: GraphQLInt,
        resolve: () => 42,
      },
    },
  }),
});

In this example, GraphQLInt is used to define the type of the myField field as an integer. The resolve function returns the value 42 as the result of the query.