How to query list of objects with array as an argument in GraphQL

You can definitely query with an array of values! Here’s what the query itself would look like: { events(containsId: [1,2,3]) { … } } And the type would look something like: const eventsType = new GraphQLObjectType({ name: ‘events’, type: // your type definition for events, args: { containsId: new GraphQLList(GraphQLID) }, … }); If you … Read more

Date and Json in type definition for graphql

Have a look at custom scalars: https://www.apollographql.com/docs/graphql-tools/scalars.html create a new scalar in your schema: scalar Date type MyType { created: Date } and create a new resolver: import { GraphQLScalarType } from ‘graphql’; import { Kind } from ‘graphql/language’; const resolverMap = { Date: new GraphQLScalarType({ name: ‘Date’, description: ‘Date custom scalar type’, parseValue(value) { … Read more

How do you prevent nested attack on GraphQL/Apollo server?

As of the time of writing, there isn’t a built-in feature in GraphQL-JS or Apollo Server to handle this concern, but it’s something that should definitely have a simple solution as GraphQL becomes more popular. This concern can be addressed with several approaches at several levels of the stack, and should also always be combined … Read more

Can a GraphQL input type inherit from another type or interface?

No, the spec does not allow input types to implement interfaces. And GraphQL type system in general does not define any form of inheritance (the extends keyword adds fields to an existing type, and isn’t for inheritance). The spec is intentionally constrained to stay simple. This means that you’re stuck repeating fields across input types. … Read more

Document a GraphQL API

It looks like there is now https://www.npmjs.com/package/graphql-docs Dynamically generated documentation explorer for GraphQL schemas. It aims to provide a better overview of a schema than GraphiQL, but without querying features. You can also generate a static documentation file based on a schema file or GraphQL endpoint: npm install -g graphql-docs graphql-docs-gen http://GRAPHQL_ENDPOINT documentation.html

Shouldn’t the login be a Query in GraphQL?

In the context of that example, login should be a Query instead of a Mutation assuming its resolver has no side-effects, at least according to the spec. However, there’s a couple of reasons you probably won’t see that done in the wild: If you’re implementing authentication, you’ll probably want to log your users’ account activity, … Read more

Can graphql return aggregate counts?

You would define a new GraphQL type that is an object that contains a list and a number. The number would be defined by a resolver function. On your GraphQL server you can define the resolver function and as part of that, you would have to write the code that performs whatever calculations and queries … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)