Questions tagged [graphql-js]

The JavaScript reference implementation for GraphQL, a query language created by Facebook for describing data requirements on complex application data models.

1291 questions
12
votes
2 answers

GraphQL mutation variables

I'm trying to do a simple mutation using GraphQL with the GraphiQL interface. My mutation looks like this: mutation M($name: String) { addGroup(name:$name) { id, name } } with variables: { "name": "ben" } But it gives me the error:…
bento
  • 4,384
  • 6
  • 38
  • 58
11
votes
4 answers

Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm

Given the following code: import { graphql } from 'graphql' import graphqlTools from 'graphql-tools' const { makeExecutableSchema } = graphqlTools const typeDefs = ` type Query { as: [A] } type A { x: Int, y: Int } ` const schema =…
Matías Fidemraizer
  • 59,064
  • 16
  • 107
  • 181
11
votes
1 answer

How to forward extension from one server to middleware server

I am using remote schema stitching on my middlware server. I am able to get the schema remotely on middleware server, defined my route like this on middleware server. app.use('/graphql', graphqlHTTP((request,res) => { const startTime = Date.now(); …
N Sharma
  • 28,073
  • 81
  • 228
  • 405
10
votes
1 answer

How to Filter List/Queries With AND/OR operators AWS Amplify JavaScript GraphQL

I am new to using AWS Amplify and GraphQL. Also just started building out React Native App - which is a lot of fun! I have a table called TimePeriods schema for it looks like this type TimePeriod @model { id: ID! name: String! startYear:…
user4770804
10
votes
1 answer

Differences between new HttpLink and createHttpLink from package apollo-link-http

In tutorial https://www.howtographql.com/vue-apollo/1-getting-started/ there is presented new HttpLink syntax, but in official docs https://www.apollographql.com/docs/link/links/http/ function createHttpLink is applied. None of these two sources…
Daniel
  • 5,039
  • 2
  • 28
  • 53
10
votes
1 answer

GraphQL and CSRF protection

I read a lot around: https://github.com/pillarjs/understanding-csrf https://security.stackexchange.com/questions/10227/csrf-with-json-post Are JSON web services vulnerable to CSRF attacks? (Nothing on the ApolloServer site:…
Fred Hors
  • 941
  • 6
  • 28
10
votes
1 answer

Gatsby.js: Filter GraphQL query by nested object property

I'm working on a news site which will have articles, each with one or multiple respective authors. If you click on an author's name, it will take you to a page displaying their information and a list of articles they have contributed to. So each…
dougmacklin
  • 2,290
  • 9
  • 37
  • 66
10
votes
1 answer

The significance of the string immediately after query type (query / mutation) GraphQL

I was wondering what the significance of the string that follows the query type, in this case "ProvisionQueues", it seems removing this from the string doesn't affect anything - is it just for logging or something. meta data? mutation…
Melbourne2991
  • 9,735
  • 10
  • 38
  • 79
9
votes
1 answer

expressGraphQL is not a function

I am learning GraphQL for my project using this tutorial: https://www.youtube.com/watch?v=ZQL7tL2S0oQ&ab_channel=WebDevSimplified and I get the error: TypeError: expressGraphQL is not a function at Object. I have already tried: this…
Swantewit
  • 159
  • 9
9
votes
1 answer

How to get a cursor for pagination in Graphql from a database?

I am having terrible problems getting a real cursor for resolving a database pagination result in GraphQL. No matter what kind of database (SQL e.g. mysql or NoSQL document e.g. mongodb) I am using, there is no way, I seem to be able to get a cursor…
LongHike
  • 2,426
  • 1
  • 23
  • 42
9
votes
3 answers

How to return both error and data in a graphql resolver?

I was thinking about ways of implementing graphql response that would contain both an error and data. Is it possible to do so without creating a type that would contain error? e.g. Mutation addMembersToTeam(membersIds: [ID!]! teamId: ID!): [Member]…
Le garcon
  • 3,929
  • 5
  • 23
  • 38
9
votes
2 answers

graphql + mongoose + typescript, how to reduce model definition duplicated

I use mongoose, typescript and graphql to build my app. I am a full-stack developer. The problem is I define the fields and types of model FIVE times. server side: models/book.ts: // first time interface IBook extends mongoose.Document { title:…
slideshowp2
  • 38,463
  • 29
  • 127
  • 255
9
votes
3 answers

Angular - Apollo: Client has not been defined yet

I'm using apollo client for graphql. I set up the client in AppApolloModule that I'm importing in AppModule. I'm making a query in a service which is also imported right in the AppModule. Although the service runs before the AppApolloModule runs and…
Manzur Khan
  • 1,962
  • 3
  • 18
  • 37
9
votes
3 answers

How to reference a specific ENUM value in GraphQL type?

I have the following schema: enum PaymentTypeName { PAYMENT_CARD PAYMENT_CARD_TOKEN } interface Payment { id: ID! type: PaymentTypeName! } type PaymentCardPayment implements Payment { id: ID! type: PaymentTypeName! card:…
Gajus
  • 55,791
  • 58
  • 236
  • 384
9
votes
2 answers

Why GraphQL `implements` need to duplicate the fields, is that mandatory? If yes, what is the underlying reasons?

Why GraphQL implements keyword need to duplicate the fields, is that mandatory? Like the examples in the document: enum Episode { NEWHOPE, EMPIRE, JEDI } interface Character { id: String name: String friends: [Character] appearsIn:…
lnshi
  • 1,434
  • 1
  • 9
  • 33