Unable to find any GraphQL type definitions for the following pointers: -"src/**/*.graphql"

See original GitHub issue

Describe the bug I have created a brand new react-native application and I, now, attempt to generate graphql schema from my backend https://__server__url__/graphql where it is exposed. I entered

$ graphql-codegen init

and followed the steps from the wizard, which produced the below codegen.yml:

overwrite: true
schema: "https://__server__url__/graphql"
documents: "src/**/*.graphql"
generates:
  src/generated/graphql.tsx:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-react-apollo"
  ./graphql.schema.json:
    plugins:
      - "introspection"

This is the package.json script I should run to generate the schema:

"schema": "graphql-codegen --config codegen.yml"

But the above command fails with the following errors:

✖src/generated/graphql.tsx
    Error: Unable to find any GraphQL type definitions for the following pointers: -"src/**/*.graphql"

...

✖ ./graphql.schema.json
    Error: Unable to find any GraphQL type definitions for the following pointers: -"src/**/*.graphql"

My backend is a nestjs application which exposes a graphql interface. My schema.gql file has been generated by type-graphql which I paste below

  1. My GraphQL schema:
# -----------------------------------------------
# !!! THIS FILE WAS GENERATED BY TYPE-GRAPHQL !!!
# !!!   DO NOT MODIFY THIS FILE BY YOURSELF   !!!
# -----------------------------------------------

"""Date custom scalar type"""
scalar Date

type Mutation {
  create_user(user: UserInput!): User!
  create_pofficer(pofficer: POfficerCreateInput!): POfficer!
  create_incident(incident: TIncidentInput!): TIncident!
  add_incident_type(incident_type: TIncidentTypeInput!): TIncidentType!
}

type POfficer {
  _id: ID!
  userid: ID!
  user: User!
}

input POfficerCreateInput {
  name: String!
  surname: String!
  phone: String!
}

type Query {
  users: [User!]!
  pofficers: [POfficer!]!
  incidents: [TIncident!]!
  incident_types: [TIncidentType!]!
}

type TIncident {
  _id: ID!
  createdAt: Date!
  incidenttype_id: ID!
  pofficer_id: ID!
  toffender_id: ID
  toffender_phone: String!
  carnumber: String!
  incident_status: String!
  pofficer: POfficer!
  toffender: User!
  incident_type: TIncidentType!
}

input TIncidentInput {
  incidenttype_id: ID!
  pofficer_id: ID!
  toffender_phone: String!
  carnumber: String!
}

type TIncidentType {
  _id: ID!
  name: String!
  description: String
}

input TIncidentTypeInput {
  name: String!
  description: String
}

type User {
  _id: ID!
  name: String!
  surname: String!
  email: String
  phone: String!
}

input UserInput {
  name: String!
  surname: String!
  email: String!
  phone: String!
}


  1. My GraphQL operations:
# Put your operations here
  1. My codegen.yml config file:
overwrite: true
schema: "https://__server__url__/graphql"
documents: "src/**/*.graphql"
generates:
  src/generated/graphql.tsx:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-react-apollo"
  ./graphql.schema.json:
    plugins:
      - "introspection"

Expected behavior Should generate typescript types from remote schema

Environment:

  • OS: Macbook pro high sierra
  • @graphql-codegen/cli: 1.8.3
  • NodeJS: v12.10.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
seyaobeycommented, Nov 21, 2019

I have solved the issue by applying the answer from this stackoverflow question here (the question is also from me) Basically I had to create a .graphql file with at least 1 operation (query or mutation). And now it works. I don’t know whether this is the real solution to this problem or a hack. Maybe it should be mentioned in the tutorial.

4reactions
dotansimhacommented, Nov 24, 2019

@aldegoeij we have an open issue for that: https://github.com/dotansimha/graphql-code-generator/issues/2349

Closing this for now. As mentioned before, either remove typescript-operations and documents: section, or add an actual operation 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to find any GraphQL type definitions for the following ...
The file your shared is your schema (as generated by your server), but it seems that you haven't created any queries or mutations...
Read more >
Typescript – Unable to find any GraphQL type definitions for the ...
I am using the @graphql-codegen/cli tool to generate typescript types out of my graphql server. Here is my codegen.yml content:
Read more >
How To Find Any Graphql Type Definitions For The ... - ADocLib
Unable to find any GraphQL type definitions for the following pointers. I found #2979 to resolve my issue. In this article we'll cover...
Read more >
Mixing Typescript and GraphQL Code Generator
Error : Unable to find any GraphQL type definitions for the following pointers: 'src/**/*.gql'. Let's solve this issue by creating our first ...
Read more >
graphql-inspector - Bountysource
Unable to find any GraphQL type definitions for the following pointers. The following errors out when use wildcard . graphql-inspector validate .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found