How to use the GraphQLSchema function from graphql

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

126
127
128
129
130
131
132
133
134
135
      type: graphql.GraphQLString
    }
  }
})

var schema = new graphql.GraphQLSchema({
  query: new graphql.GraphQLObjectType({
    name: 'Query'
    fields: {
      film: {
fork icon34
star icon639
watch icon14

+ 3 other calls in file

175
176
177
178
179
180
181
182
183
184
      }
    };
  }
});

const Schema = new GraphQLSchema({
  query: Query
});

module.exports = Schema;
fork icon54
star icon304
watch icon13

+ 3 other calls in file

183
184
185
186
187
188
189
190
191
192
使用指定的 query 及 mutation(可选)的根类型来创建 Schema。生成的 Schema 可用于之后的验证器和执行器。

#### 示例

```js
var MyAppSchema = new GraphQLSchema({
  query: MyAppQueryRootType
  mutation: MyAppMutationRootType
});
```
fork icon0
star icon188
watch icon18

+ 3 other calls in file

43
44
45
46
47
48
49
50
51
52
            type: graphql.GraphQLString
        }
    })
});

const apiSchema = new graphql.GraphQLSchema({
    query: queryType
});

exports.getQuery = function (req, res, next) {
fork icon43
star icon139
watch icon16

103
104
105
106
107
108
109
110
111
      }
    }
  }
});

module.exports = new GraphQLSchema({
  query: RootQuery
});
```
fork icon9
star icon18
watch icon2

91
92
93
94
95
96
97
98
99
      }
    }
  }
});

const ChockNorrisSchema = new GraphQLSchema({
  query: ChuckNorrisQueryType,
  mutation: ChuckNorrisMutationType
});
fork icon1
star icon5
watch icon2

47
48
49
50
51
52
53
54
55
56
57
        return result.next();
    }
});


module.exports = {
    schema: new GraphQLSchema({
        query: new GraphQLObjectType({
            name: 'RootQueryType',
            fields: {
                hello: {
fork icon2
star icon26
watch icon0

24
25
26
27
28
29
30
31
32
33
    assertCompositeType = _require2.assertCompositeType,
    isInterfaceType = _require2.isInterfaceType,
    getNullableType = _require2.getNullableType,
    GraphQLInterfaceType = _require2.GraphQLInterfaceType,
    GraphQLObjectType = _require2.GraphQLObjectType,
    GraphQLSchema = _require2.GraphQLSchema;

var _require3 = require('./GraphQLCompilerPublic'),
    CompilerContext = _require3.CompilerContext,
    SchemaUtils = _require3.SchemaUtils,
fork icon0
star icon1
watch icon2

12
13
14
15
16
17
18
19
20
21
});
// const mutation = new GraphQLObjectType({
//   name: 'Mutation',
//   fields: {},
// });
exports.schema = new graphql_1.GraphQLSchema({
    query,
    // mutation,
});
exports.permissions = (0, graphql_shield_1.shield)({
fork icon0
star icon0
watch icon1

17
18
19
20
21
22
23
24
25
26
27
  await initializeDatabase()
  startServer(app);
})();


function addGraphQlApi(app) {
  const schema = new graphql.GraphQLSchema({
    "query": schemaDefinition
  });
  app.use("/graphql", graphqlHTTP({
    "schema": schema,
fork icon0
star icon0
watch icon4

+ 46 other calls in file

125
126
127
128
129
130
                return (0, recipe_1.likeRecipe)(id, args.recipeId);
            },
        },
    },
});
exports.default = new graphql_1.GraphQLSchema({ query: RecipeRootQuery, mutation });
fork icon0
star icon0
watch icon0

72
73
74
75
76
77
78
79
80
81
                return todos_json_1.default[index];
            },
        },
    }),
});
const root = new graphql_1.GraphQLSchema({
    query: RootQuery,
    mutation,
});
exports.default = root;
fork icon0
star icon0
watch icon0

+ 3 other calls in file

1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
    } = getMutationsForList(list);
    updateManyByList[list.listKey] = updateManyInput;
    return mutations;
  }), extraFields.mutation)
});
const graphQLSchema = new graphql$1.GraphQLSchema({
  query: query.graphQLType,
  mutation: mutation.graphQLType,
  // not about behaviour, only ordering
  types: [...collectTypes(lists, updateManyByList), mutation.graphQLType]
fork icon0
star icon0
watch icon0

76
77
78
79
80
81
82
83
        }
    }
})




module.exports = new GraphQLSchema({ query: RootQuery, mutation: Mutation })
fork icon0
star icon0
watch icon0

240
241
242
243
244
245
246
247
248
249
                return user_js_1.userCollection.findById(args.id);
            },
        },
    },
});
const userSchema = new graphql_1.GraphQLSchema({
    mutation: userMutation,
});
console.log(cartType);
exports.default = userSchema;
fork icon0
star icon0
watch icon0

+ 3 other calls in file

38
39
40
41
42
43
44
45
46
                return product_js_1.default.find({});
            },
        },
    },
});
const graphQlSchema = new graphql_1.GraphQLSchema({
    query,
});
exports.default = graphQlSchema;
fork icon0
star icon0
watch icon0