-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
GraphQL: Using generic Mutation can lead to unwanted result #5925
Comments
The sintax for creating a relationField through the generic method is the same of the REST API. So it whould be: mutation {
objects {
create(
className: "SomeClass"
fields: {
relation: {
__op: "Batch",
ops: [{ __op: "AddRelation", objects: [{ __type: "Pointer", className: "Country", objectId: "GFFCf5dxKW" }]}]
}
) {
objectId
}
}
} See test case here: https://github.com/parse-community/parse-server/blob/master/spec/ParseGraphQLServer.spec.js#L5119 I know it is not intuitive and need docs. The developers can always opt for the custom operations though. The idea behind the generic operations is to keep the schemaless feature in Parse GraphQL API but we can discuss it further and perhaps remove them. |
I was thinking little bit more here. Maybe an option could be just remove all generic operations and build new operations to manipulate the schema? |
Yes not intuitive 😉 |
It's totally what i suggest, a developer could use the full potential of A example of DX:
|
Type Proposaltype Mutation {
createClass(input: CreateClassInput): Boolean
updateClass(input: UpdateClassInput): Boolean
createSchema(input: [CreateClassInput]): Boolean
updateSchema(input: [UpdateClassInput]): Boolean
}
input AddArrayInput {
name: String!
}
input AddRelationInput {
name: String!
targetClass: String!
}
input AddNumberInput {
name: String!
}
input AddBooleanInput {
name: String!
}
input AddFileInput {
name: String!
}
input AddPointerInput {
name: String!
targetClass: String!
}
input AddDateInput {
name: String!
}
input AddGeoPointInput {
name: String!
}
input AddObjectInput {
name: String!
}
input AddStringInput {
name: String!
}
input DeleteField {
name: String!
}
input SchemaClassInput {
addArrays: [AddArrayInput!]
addStrings: [AddRelationInput!]
addNumbers: [AddRelationInput!]
addDates: [AddRelationInput!]
addGeoPoints: [AddRelationInput!]
addFiles: [AddRelationInput!]
addRelations: [AddRelationInput!]
addObjects: [AddObjectsInput!]
addPointers: [AddPointersInput!]
addPolygons: [AddPolygonsInput!]
addBooleans: [AddBooleansInput!]
}
input CreateClassInput {
className: String!
schema: SchemaClassInput
}
input UpdateClassInput {
className: ClassNameEnum!
schema: SchemaClassInput
} Mutation example: mutation {
createClass (input: {
className: "SomeClass"
schema: {
addArrays: [
{name: "anArray"}
]
addRelations: [
{name: "users", targetClass: "User"}
{name: "products", targetClass: "Product"}
]
}
})
} |
Issue Description
Using a generic Mutation can lead to unwanted result, more specifically on data types like: Array/Relation.
Steps to reproduce
Create a new Object (with new field) and an array of
Pointers
Expected Results
relation
field must be aRelation
Actual Outcome
The data type is interpreted as an Array
Environment Setup
Server
Database
Suggestion
I think that generic Mutations isn't suitable in real GraphQL app but it's useful for testing the current GraphQL feature. The generic
Mutation
currently seems to be a black box and can be confusing for new developers who are not familiar with SDKs (Polygon, ACL, Pointer, etc...)In fact, I think that in most applications that will use the
Parse GraphQL
asAPI
, the SDKs will be used little or not at all to interact with theGraphQL
because it is not comfortable and really logical to combine aSDK
and aAPI GraphQL
in terms of developer experience.We should teach developers to create first a schema with a well designed
createClass
/createSchema
Mutation
and then use a specificMutation
What do you think about this @davimacedo @omairvaiyani @douglasmuraoka ?
The text was updated successfully, but these errors were encountered: