Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GQL Mutation - Receiving unexpected "[Object: null prototype]" #90

Closed
thesrs02 opened this issue Nov 30, 2019 · 2 comments
Closed

GQL Mutation - Receiving unexpected "[Object: null prototype]" #90

thesrs02 opened this issue Nov 30, 2019 · 2 comments

Comments

@thesrs02
Copy link

thesrs02 commented Nov 30, 2019

Sending payload in Mutation also returns this "[Object: null prototype]" as a reference key for the actual payload - seems to be a bug.

Error:
image

Workaround:
JSON.parse(JSON.stringify(payload))

Reproduce:
server.js config for GQL Fastify

app.register(GQL, {
  schema: makeExecutableSchema({typeDefs, resolvers})
});

Resolver

Mutation: {
    createUser: async (_, {payload}) => {
      console.log(payload);
    }
  }

TypeDefs / Schema

		type User {
			id: ID
			firstName: String
			lastName: String
			username: String
			email: String
			avatar: String
			birthDate: Float
			startDate: Float
		}

		input UserInput {
			id: ID
			firstName: String!
			lastName: String!
			username: String
			email: String!
			avatar: String
			birthDate: Float
			startDate: Float
		}

		type Query {
			getOneUser(id: ID!): User
	  }

		type Mutation {
			createUser(payload: UserInput): User
		}

Mutation Query

mutation {
  createUser(payload:{
      id: "52jk452k3j452jk3452k3452345kjfac",
      firstName: "Rehan",
      lastName: "Haider",
      username: "rehanhaider",
      email: "thesrs02@gmail.com",
      avatar: "https://tinyurl.com/qsqau3r",
      birthDate: 41234123412341,
      startDate: 41234123412344
    }) {
    firstName
    lastName
    lastName
    username
    email
    avatar
    birthDate
    startDate
  } 
}

Might be similar to this: apollographql/apollo-server#3149

Let me know if more details are required.

@mcollina
Copy link
Collaborator

It would be good to get a full example to reproduce.
Moreover, if you'd like to send a PR with a fix, It would be fantastic.

@thesrs02
Copy link
Author

Okay so the prototype is not related to GraphQL or Fastify-GraphQL. It comes from Node and I don't think they're changing it anytime soon. Ref: nodejs/node#30183

After spending 2+ hours, I've found and tested that it just adds verbosity and doesn't actually cause any harm.

Fastify:
image

Not a big issue and workarounds are available so closing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants