How to use the execute function from graphql

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

152
153
154
155
156
157
158
159
160
161
var source = new graphql.Source(query)
var documentAST = graphql.parse(source)

agent.startTransaction('foo')

graphql.execute(schema, documentAST, rootValue).then(function (response) {
  t.ok(agent.currentSpan === null, 'no currentSpan .execute().then(...)')
  agent.endTransaction()
  t.deepLooseEqual(response, { data: { hello: 'Hello world!' } })
  agent.flush()
fork icon211
star icon536
watch icon296

+ 23 other calls in file

179
180
181
182
183
184
185
186
187
      // Throw GraphQLErrors from GraphQL execution.
      // Errors must be wrapped in GraphQLError for customFormatErrorFn to handle them correctly.
      throw new GraphQLError(error.message, undefined, undefined, undefined, undefined, error)
    }

    return execute(args)
  },
  customFormatErrorFn: (error) => customFormatErrorFn(error, request, requestParams),
}))
fork icon33
star icon66
watch icon0

59
60
61
62
63
64
65
66
67
68
    .then(result => res.json(result))
    .catch(error => res.status(500).send(error));
});

app.post('/stitching', (req, res) => {
  execute({
    schema: stitching,
    document: stitchingParse(req.body.query),
    contextValue: {},
  })
fork icon0
star icon0
watch icon1

387
388
389
390
391
392
393
394
395
396
  assumeValid: true
});
return async function (args, context) {
  var _result$errors;
  let rootValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  const result = await graphql.execute({
    schema,
    document,
    contextValue: context,
    variableValues: args,
fork icon0
star icon0
watch icon1

+ 8 other calls in file

1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
};
const validationErrors = graphql$1.validate(schema, document);
if (validationErrors.length > 0) {
  throw validationErrors[0];
}
const result = await graphql$1.execute({
  schema,
  document,
  contextValue: context,
  variableValues: Object.fromEntries(
fork icon0
star icon0
watch icon0