Skip to content

Apollo Server v3 #20

Description

@inkiltie
  1. Because by default when you type http://localhost:5001/api/graphql new AS3 playground opens a new window https://studio.apollographql.com/sandbox/explorer, this new url needs to be added to CORS urls in settings-*
"api": "http://localhost:5001",
"app": "http://localhost:5000",
"gql": "https://studio.apollographql.com"
  1. In the AS3 migration guide https://www.apollographql.com/docs/apollo-server/migration/#graphql-playground there is a way to use old playground at localhost:
import { ApolloServerPluginLandingPageGraphQLPlayground,
         ApolloServerPluginLandingPageDisabled } from 'apollo-server-core';

new ApolloServer({
  plugins: [
    process.env.NODE_ENV === 'production'
      ? ApolloServerPluginLandingPageDisabled()
      : ApolloServerPluginLandingPageGraphQLPlayground(),
  ],
});

But even though I can try both ways I always receive either null or error while trying to execute something, for example:

query Query {
  user {
    name {
      last
      first
    }
    emailAddress
    _id
  }
}
_______________
{
  "data": {
    "user": null
  }
}

or

query Query {
  documents {
    _id
    userId
    title
    status
    createdAt
    updatedAt
    content
  }
}
_______________
{
  "errors": [
    {
      "message": "Cannot read property '_id' of null",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "documents"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: Cannot read property '_id' of null",
            "    at _callee$ (webpack://nodejs-server/./api/documents/graphql/queries.js?:26:38)",
            "    at tryCatch (/Users/vancoder/Git/node2/node_modules/regenerator-runtime/runtime.js:63:40)",
            "    at Generator.invoke [as _invoke] (/Users/vancoder/Git/node2/node_modules/regenerator-runtime/runtime.js:294:22)",
            "    at Generator.next (/Users/vancoder/Git/node2/node_modules/regenerator-runtime/runtime.js:119:21)",
            "    at asyncGeneratorStep (/Users/vancoder/Git/node2/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)",
            "    at _next (/Users/vancoder/Git/node2/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)",
            "    at /Users/vancoder/Git/node2/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7",
            "    at new Promise (<anonymous>)",
            "    at /Users/vancoder/Git/node2/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12",
            "    at documents (webpack://nodejs-server/./api/documents/graphql/queries.js?:38:25)"
          ]
        }
      }
    }
  ],
  "data": {
    "documents": null
  }
}

Is it related to cookies or am I just missing something here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions