drupal-graphql / graphql

GraphQL integration for Drupal 9/10
288 stars 201 forks source link

I cant get any of your intro examples to work #1284

Closed laurencefass closed 2 years ago

laurencefass commented 2 years ago

Im trying to work through your documentation and failing.

Source: https://joao-garin.gitbook.io/graphql-docs-update/queries/querying-nodes

Im using v4 of graphql. I am using the basic setup with modules enabled and i havent changed or added any schema or configuration since installing the module.

e.g. (this fails whether i exclude the out braces or not)

{
query {
    user: currentUserContext{
      ...on User {
        name
      }
    }
  }
}

results in:

{
  "errors": [
    {
      "message": "Cannot query field \"query\" on type \"Query\".",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 2,
          "column": 1
        }
      ]
    },
    {
      "message": "Unknown type \"User\".",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 4,
          "column": 13
        }
      ]
    }
  ]
}

Another test fail:

query {
  nodeById(id: "1", language: en) {
    entityId
    entityCreated

    title
    status

    ... on NodeArticle {
      fieldSubtitle
    }
  }
}

results in:

{
  "errors": [
    {
      "message": "Cannot query field \"nodeById\" on type \"Query\".",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    },
    {
      "message": "Unknown type \"NodeArticle\". Did you mean \"Article\"?",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 9,
          "column": 12
        }
      ]
    }
  ]
}

Another test fail:

query {
  nodeQuery(limit: 10, offset: 0, filter: {conditions: [{operator: EQUAL, field: "type", value: ["article"]}]}) {
    entities {
      entityLabel
    }
  }
}

results in

{
  "errors": [
    {
      "message": "Cannot query field \"nodeQuery\" on type \"Query\".",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ]
}

summary: i cant get any of the introductory examples to work. note again: i havent changed or added any schema or configuration since installing the module.

hugronaphor commented 2 years ago

v4 of graphql only provides all functionality for you to build your own schema while your doc link refers to v3.x

laurencefass commented 2 years ago

thanks for info.